-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - scrapeninja #15753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - scrapeninja #15753
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
baa56ab
scrapeninja init
luancazarine 3f31cb3
[Components] scrapeninja #15137
luancazarine eac6a0c
pnpm update
luancazarine cdc2434
some adjusts
luancazarine 35beaba
Update components/scrapeninja/actions/scraping-with-js-rendering/scra…
luancazarine 113f341
Update components/scrapeninja/scrapeninja.app.mjs
luancazarine 49a3b46
Renaming action files to match their names
GTFalcao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
components/scrapeninja/actions/non-js-scraping/non-js-scraping.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import scrapeninja from "../../scrapeninja.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "scrapeninja-non-js-scraping", | ||
| name: "Scrape without JS", | ||
| description: "Use high-performance web scraping endpoint with Chrome browser TLS fingerprint, but without JavaScript execution and real browser overhead. [See the documentation](https://scrapeninja.net/docs/api-reference/scrape/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| scrapeninja, | ||
| url: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "url", | ||
| ], | ||
| }, | ||
| headers: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "headers", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| retryNum: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "retryNum", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| geo: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "geo", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| proxy: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "proxy", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| followRedirects: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "followRedirects", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "timeout", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| textNotExpected: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "textNotExpected", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| statusNotExpected: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "statusNotExpected", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| extractor: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "extractor", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| try { | ||
| const response = await this.scrapeninja.scrapeNonJs({ | ||
| $, | ||
| data: { | ||
| url: this.url, | ||
| headers: parseObject(this.headers), | ||
| retryNum: this.retryNum, | ||
| geo: this.geo, | ||
| proxy: this.proxy, | ||
| followRedirects: this.followRedirects, | ||
| timeout: this.timeout, | ||
| textNotExpected: parseObject(this.textNotExpected), | ||
| statusNotExpected: parseObject(this.statusNotExpected), | ||
| extractor: this.extractor, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully scraped the URL"); | ||
| return response; | ||
| } catch ({ response: { data } }) { | ||
| throw new ConfigurationError(data.message || data.stderr); | ||
| } | ||
| }, | ||
| }; | ||
231 changes: 231 additions & 0 deletions
231
components/scrapeninja/actions/scraping-with-js-rendering/scraping-with-js-rendering.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,231 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import { | ||
| clearObj, | ||
| parseError, parseObject, | ||
| } from "../../common/utils.mjs"; | ||
| import scrapeninja from "../../scrapeninja.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "scrapeninja-scraping-with-js-rendering", | ||
| name: "Scrape with JS Rendering", | ||
| description: "Uses the ScrapeNinja real Chrome browser engine to scrape pages that require JS rendering. [See the documentation](https://scrapeninja.net/docs/api-reference/scrape-js/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| scrapeninja, | ||
| url: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "url", | ||
| ], | ||
| }, | ||
| waitForSelector: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "waitForSelector", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| postWaitTime: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "postWaitTime", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| dumpIframe: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "dumpIframe", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| waitForSelectorIframe: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "waitForSelectorIframe", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| extractorTargetIframe: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "extractorTargetIframe", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| headers: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "headers", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| retryNum: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "retryNum", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| geo: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "geo", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| proxy: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "proxy", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "timeout", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| textNotExpected: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "textNotExpected", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| statusNotExpected: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "statusNotExpected", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| blockImages: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "blockImages", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| blockMedia: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "blockMedia", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| screenshot: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "screenshot", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| catchAjaxHeadersUrlMask: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "catchAjaxHeadersUrlMask", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| viewportWidth: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "viewportWitdh", | ||
| ], | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| viewportHeight: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "viewportHeight", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| viewportDeviceScaleFactor: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "viewportDeviceScaleFactor", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| viewportHasTouch: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "viewportHasTouch", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| viewportIsMobile: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "viewportIsMobile", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| viewportIsLandscape: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "viewportIsLandscape", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| extractor: { | ||
| propDefinition: [ | ||
| scrapeninja, | ||
| "extractor", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| try { | ||
| const viewport = clearObj({ | ||
| width: this.viewportWidth, | ||
| height: this.viewportHeight, | ||
| deviceScaleFactor: this.viewportDeviceScaleFactor, | ||
| hasTouch: this.viewportHasTouch, | ||
| isMobile: this.viewportIsMobile, | ||
| isLandscape: this.viewportIsLandscape, | ||
| }); | ||
|
|
||
| const data = clearObj({ | ||
| url: this.url, | ||
| waitForSelector: this.waitForSelector, | ||
| postWaitTime: this.postWaitTime, | ||
| dumpIframe: this.dumpIframe, | ||
| waitForSelectorIframe: this.waitForSelectorIframe, | ||
| extractorTargetIframe: this.extractorTargetIframe, | ||
| headers: parseObject(this.headers), | ||
| retryNum: this.retryNum, | ||
| geo: this.geo, | ||
| proxy: this.proxy, | ||
| timeout: this.timeout, | ||
| textNotExpected: parseObject(this.textNotExpected), | ||
| statusNotExpected: parseObject(this.statusNotExpected), | ||
| blockImages: this.blockImages, | ||
| blockMedia: this.blockMedia, | ||
| screenshot: this.screenshot, | ||
| catchAjaxHeadersUrlMask: this.catchAjaxHeadersUrlMask, | ||
| extractor: this.extractor, | ||
| }); | ||
|
|
||
| if (Object.entries(viewport).length) { | ||
| data.viewport = viewport; | ||
| } | ||
|
|
||
| const response = await this.scrapeninja.scrapeJs({ | ||
| $, | ||
| data, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully scraped ${this.url} with JS rendering`); | ||
| return response; | ||
| } catch ({ response: { data } }) { | ||
| throw new ConfigurationError(parseError(data)); | ||
| } | ||
| }, | ||
| }; | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luancazarine can you rename the actual action names / slugs? Since they are new components I think it'd be best for them to match the name before being shipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filenames are still the same - maybe the commit wasn't pushed?
/actions/non-js-scraping/non-js-scraping.mjsshould match the action name, as in
/actions/scrape-without-js/scrape-without-js.mjsThe same goes for the component key, for both components