-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[Components] scrapingant #13316 #15379
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
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
87adde7
Added actions
lcaresia 67f0132
Done requests changes
lcaresia 4fb8e43
Merge branch 'master' into issue-13316
lcaresia 453288c
Merge branch 'master' into issue-13316
lcaresia 369e83d
Update general-extraction.mjs
lcaresia 80bc1cb
Update components/scrapingant/scrapingant.app.mjs
lcaresia a84b4b9
Update components/scrapingant/scrapingant.app.mjs
lcaresia 1312bba
Update components/scrapingant/scrapingant.app.mjs
lcaresia f9a9816
Update components/scrapingant/scrapingant.app.mjs
lcaresia 3308015
Added actions
lcaresia 5a9e219
Merge branch 'master' into issue-13316
lcaresia e6dc0d0
Merge branch 'master' into issue-13316
lcaresia a8db00a
Merge branch 'master' into issue-13316
lcaresia dbda1e9
Done requests changes
lcaresia 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
86 changes: 86 additions & 0 deletions
86
components/scrapingant/actions/general-extraction/general-extraction.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,86 @@ | ||
| import app from "../../scrapingant.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "scrapingant-general-extraction", | ||
| name: "General Extraction", | ||
| description: "Send a request using the standard extraction method of ScrapingAnt. [See the documentation](https://docs.scrapingant.com/request-response-format)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| url: { | ||
| propDefinition: [ | ||
| app, | ||
| "url", | ||
| ], | ||
| }, | ||
| browser: { | ||
| propDefinition: [ | ||
| app, | ||
| "browser", | ||
| ], | ||
| }, | ||
| returnPageSource: { | ||
| propDefinition: [ | ||
| app, | ||
| "returnPageSource", | ||
| ], | ||
| }, | ||
| cookies: { | ||
| propDefinition: [ | ||
| app, | ||
| "cookies", | ||
| ], | ||
| }, | ||
| jsSnippet: { | ||
| propDefinition: [ | ||
| app, | ||
| "jsSnippet", | ||
| ], | ||
| }, | ||
| proxyType: { | ||
| propDefinition: [ | ||
| app, | ||
| "proxyType", | ||
| ], | ||
| }, | ||
| proxyCountry: { | ||
| propDefinition: [ | ||
| app, | ||
| "proxyCountry", | ||
| ], | ||
| }, | ||
| waitForSelector: { | ||
| propDefinition: [ | ||
| app, | ||
| "waitForSelector", | ||
| ], | ||
| }, | ||
| blockResource: { | ||
| propDefinition: [ | ||
| app, | ||
| "blockResource", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.generalExtraction({ | ||
| $, | ||
| params: { | ||
| url: this.url, | ||
| browser: this.browser, | ||
| return_page_source: this.returnPageSource, | ||
| cookies: this.cookies, | ||
| js_snippet: this.jsSnippet, | ||
| proxy_type: this.proxyType, | ||
| proxy_country: this.proxyCountry, | ||
| wait_for_selector: this.waitForSelector, | ||
| block_resource: this.blockResource, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", "Successfully sent the request to ScrapingAnt"); | ||
|
|
||
| return response; | ||
| }, | ||
| }; | ||
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,164 @@ | ||
| export default { | ||
| PROXY_COUNTRIES: [ | ||
| { | ||
| label: "World", | ||
| value: "", | ||
| }, | ||
| { | ||
| label: "Brazil", | ||
| value: "BR", | ||
| }, | ||
| { | ||
| label: "Canada", | ||
| value: "CA", | ||
| }, | ||
| { | ||
| label: "China", | ||
| value: "CN", | ||
| }, | ||
| { | ||
| label: "Czech Republic", | ||
| value: "CZ", | ||
| }, | ||
| { | ||
| label: "France", | ||
| value: "FR", | ||
| }, | ||
| { | ||
| label: "Germany", | ||
| value: "DE", | ||
| }, | ||
| { | ||
| label: "Hong Kong", | ||
| value: "HK", | ||
| }, | ||
| { | ||
| label: "India", | ||
| value: "IN", | ||
| }, | ||
| { | ||
| label: "Indonesia", | ||
| value: "ID", | ||
| }, | ||
| { | ||
| label: "Italy", | ||
| value: "IT", | ||
| }, | ||
| { | ||
| label: "Israel", | ||
| value: "IL", | ||
| }, | ||
| { | ||
| label: "Japan", | ||
| value: "JP", | ||
| }, | ||
| { | ||
| label: "Netherlands", | ||
| value: "NL", | ||
| }, | ||
| { | ||
| label: "Poland", | ||
| value: "PL", | ||
| }, | ||
| { | ||
| label: "Russia", | ||
| value: "RU", | ||
| }, | ||
| { | ||
| label: "Saudi Arabia", | ||
| value: "SA", | ||
| }, | ||
| { | ||
| label: "Singapore", | ||
| value: "SG", | ||
| }, | ||
| { | ||
| label: "South Korea", | ||
| value: "KR", | ||
| }, | ||
| { | ||
| label: "Spain", | ||
| value: "ES", | ||
| }, | ||
| { | ||
| label: "United Kingdom", | ||
| value: "GB", | ||
| }, | ||
| { | ||
| label: "United Arab Emirates", | ||
| value: "AE", | ||
| }, | ||
| { | ||
| label: "USA", | ||
| value: "US", | ||
| }, | ||
| { | ||
| label: "Vietnam", | ||
| value: "VN", | ||
| }, | ||
| ], | ||
| PROXY_TYPES: [ | ||
| { | ||
| label: "Residential", | ||
| value: "residential", | ||
| }, | ||
| { | ||
| label: "Datacenter", | ||
| value: "datacenter", | ||
| }, | ||
| ], | ||
| RESOURCE_TYPES: [ | ||
| { | ||
| label: "Document", | ||
| value: "document", | ||
| }, | ||
| { | ||
| label: "Stylesheet", | ||
| value: "stylesheet", | ||
| }, | ||
| { | ||
| label: "Image", | ||
| value: "image", | ||
| }, | ||
| { | ||
| label: "Media", | ||
| value: "media", | ||
| }, | ||
| { | ||
| label: "Font", | ||
| value: "font", | ||
| }, | ||
| { | ||
| label: "Script", | ||
| value: "script", | ||
| }, | ||
| { | ||
| label: "Texttrack", | ||
| value: "texttrack", | ||
| }, | ||
| { | ||
| label: "XHR", | ||
| value: "xhr", | ||
| }, | ||
| { | ||
| label: "Fetch", | ||
| value: "fetch", | ||
| }, | ||
| { | ||
| label: "Eventsource", | ||
| value: "eventsource", | ||
| }, | ||
| { | ||
| label: "Websocket", | ||
| value: "websocket", | ||
| }, | ||
| { | ||
| label: "Manifest", | ||
| value: "manifest", | ||
| }, | ||
| { | ||
| label: "Other", | ||
| value: "other", | ||
| }, | ||
| ], | ||
| }; |
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
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 |
|---|---|---|
| @@ -1,11 +1,91 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import constants from "./common/constants.mjs"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "scrapingant", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| url: { | ||
| type: "string", | ||
| label: "URL", | ||
| description: "URL to scrape. This is a required parameter", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| browser: { | ||
| type: "boolean", | ||
| label: "Browser", | ||
| description: "Enables using a headless browser for scraping", | ||
| optional: true, | ||
| }, | ||
| returnPageSource: { | ||
| type: "boolean", | ||
| label: "Return Page Source", | ||
| description: "Enables returning data returned by the server and unaltered by the browser. Default: false. When true - JS won't be rendered. This feature works only with `browser=true`", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| optional: true, | ||
| }, | ||
| cookies: { | ||
| type: "string", | ||
| label: "Cookies", | ||
| description: "Cookies to pass with a scraping request to the target site, i.e.: `cookie_name1=cookie_value1;cookie_name2=cookie_value2`", | ||
| optional: true, | ||
| }, | ||
| jsSnippet: { | ||
| type: "string", | ||
| label: "JS Snippet", | ||
| description: "Base64 encoded JS snippet to run once page being loaded in the ScrapingAnt browser. This feature works only with `browser=true`", | ||
| optional: true, | ||
| }, | ||
| proxyType: { | ||
| type: "string", | ||
| label: "Proxy Type", | ||
| description: "Specifies proxy type to make request from", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| options: constants.PROXY_TYPES, | ||
| optional: true, | ||
| }, | ||
| proxyCountry: { | ||
| type: "string", | ||
| label: "Proxy Country", | ||
| description: "Specifies the proxy country to make the request from", | ||
| options: constants.PROXY_COUNTRIES, | ||
| optional: true, | ||
| }, | ||
| waitForSelector: { | ||
| type: "string", | ||
| label: "Wait for Selector", | ||
| description: "The CSS selector of the element our service will wait for before returning result. This feature works only with `browser=true`", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| optional: true, | ||
| }, | ||
| blockResource: { | ||
| type: "string[]", | ||
| label: "Block Resource", | ||
| description: "Prevents cloud browser from loading specified resource types. Available resource types: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`, `websocket`, `manifest`, `other`. This feature works only with `browser=true`", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.scrapingant.com/v2"; | ||
| }, | ||
| async _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| headers, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| headers: { | ||
| ...headers, | ||
| "x-api-key": `${this.$auth.api_token}`, | ||
| }, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async generalExtraction(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/general", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Uh oh!
There was an error while loading. Please reload this page.