-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - zenscrape #15467
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 - zenscrape #15467
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
19 changes: 19 additions & 0 deletions
19
components/zenscrape/actions/get-credit-status/get-credit-status.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,19 @@ | ||
| import zenscrape from "../../zenscrape.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "zenscrape-get-credit-status", | ||
| name: "Get Credit Status", | ||
| description: "Retrieve the number of remaining credits in Zenscrape. [See the documentation](https://app.zenscrape.com/documentation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| zenscrape, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.zenscrape.getStatus({ | ||
| $, | ||
| }); | ||
| $.export("$summary", "Successfully retrieved credit status."); | ||
| return response; | ||
| }, | ||
| }; |
56 changes: 56 additions & 0 deletions
56
components/zenscrape/actions/get-website-content/get-website-content.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,56 @@ | ||
| import zenscrape from "../../zenscrape.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "zenscrape-get-website-content", | ||
| name: "Get Website Content", | ||
| description: "Retrieve the content of a website. [See the documentation](https://app.zenscrape.com/documentation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| zenscrape, | ||
| url: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "url", | ||
| ], | ||
| }, | ||
| premium: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "premium", | ||
| ], | ||
| }, | ||
| location: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "location", | ||
| ], | ||
| }, | ||
| keepHeaders: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "keepHeaders", | ||
| ], | ||
| }, | ||
| render: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "render", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.zenscrape.getContent({ | ||
| $, | ||
| params: { | ||
| url: this.url, | ||
| premium: this.premium, | ||
| location: this.location, | ||
| keep_headers: this.keepHeaders, | ||
| render: this.render, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully scraped website \`${this.url}.\``); | ||
| 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
92 changes: 92 additions & 0 deletions
92
components/zenscrape/sources/website-content-updated/website-content-updated.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,92 @@ | ||
| import zenscrape from "../../zenscrape.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
| import md5 from "md5"; | ||
|
|
||
| export default { | ||
| key: "zenscrape-website-content-updated", | ||
| name: "Website Content Updated", | ||
| description: "Emit new event when the content of a URL has updated. [See the documentation](https://app.zenscrape.com/documentation)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| zenscrape, | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| url: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "url", | ||
| ], | ||
| }, | ||
| premium: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "premium", | ||
| ], | ||
| }, | ||
| location: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "location", | ||
| ], | ||
| }, | ||
| keepHeaders: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "keepHeaders", | ||
| ], | ||
| }, | ||
| render: { | ||
| propDefinition: [ | ||
| zenscrape, | ||
| "render", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getContentHash() { | ||
| return this.db.get("contentHash"); | ||
| }, | ||
| _setContentHash(contentHash) { | ||
| this.db.set("contentHash", contentHash); | ||
| }, | ||
| generateMeta() { | ||
| const ts = Date.now(); | ||
| return { | ||
| id: ts, | ||
| summary: "Website Content Updated", | ||
| ts, | ||
| }; | ||
| }, | ||
| }, | ||
| async run() { | ||
| const contentHash = this._getContentHash(); | ||
|
|
||
| const content = await this.zenscrape.getContent({ | ||
| params: { | ||
| url: this.url, | ||
| premium: this.premium, | ||
| location: this.location, | ||
| keep_headers: this.keepHeaders, | ||
| render: this.render, | ||
| }, | ||
| }); | ||
|
|
||
| const newContentHash = md5(JSON.stringify(content)); | ||
|
|
||
| if (newContentHash === contentHash) { | ||
| return; | ||
| } | ||
|
|
||
| this._setContentHash(newContentHash); | ||
|
|
||
| const meta = this.generateMeta(); | ||
| this.$emit(content, meta); | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
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,67 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "zenscrape", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| url: { | ||
| type: "string", | ||
| label: "URL", | ||
| description: "The target site you want to scrape", | ||
| }, | ||
| premium: { | ||
| type: "boolean", | ||
| label: "Premium", | ||
| description: "Uses residential proxies, unlocks sites that are hard to scrape. Counts as 20 credits towards your quota.", | ||
| optional: true, | ||
| }, | ||
| location: { | ||
| type: "string", | ||
| label: "Location", | ||
| description: "If premium=`false` possible locations are 'na' (North America) and 'eu' (Europe). If premium=`true` you can choose a location from Zenscrape's [list of 230+ countries](https://app.zenscrape.com/documentation#proxyLocationList)", | ||
| optional: true, | ||
| }, | ||
| keepHeaders: { | ||
| type: "boolean", | ||
| label: "Keep Headers", | ||
| description: "Allow to pass through forward headers (e.g. user agents, cookies)", | ||
| optional: true, | ||
| }, | ||
| render: { | ||
| type: "boolean", | ||
| label: "Render", | ||
| description: "Use a headless browser to fetch content that relies on javascript. Counts as 5 credits towards your quota.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://app.zenscrape.com/api/v1"; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, | ||
| path, | ||
| ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| apikey: this.$auth.api_key, | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| getContent(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/get", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| getStatus(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/status", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; |
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.