-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Apify (API Key) - update scrape-single-url #18210
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 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
44 changes: 6 additions & 38 deletions
44
components/apify/actions/scrape-single-url/scrape-single-url.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 |
|---|---|---|
| @@ -1,57 +1,25 @@ | ||
| import apify from "../../apify.app.mjs"; | ||
| import { ACTOR_ID } from "../../common/constants.mjs"; | ||
| import { gotScraping } from "got-scraping"; | ||
|
|
||
| export default { | ||
| key: "apify-scrape-single-url", | ||
| name: "Scrape Single URL", | ||
| description: "Executes a scraper on a specific website and returns its content as text. This action is perfect for extracting content from a single page.", | ||
| version: "0.0.4", | ||
| description: "Executes a scraper on a specific website and returns its content as HTML. This action is perfect for extracting content from a single page. [See the documentation](https://docs.apify.com/sdk/js/docs/examples/crawl-single-url)", | ||
| version: "0.1.0", | ||
| type: "action", | ||
| props: { | ||
| apify, | ||
| url: { | ||
| type: "string", | ||
| label: "URL", | ||
| description: "The URL of the web page to scrape.", | ||
| optional: false, | ||
| }, | ||
| crawlerType: { | ||
| type: "string", | ||
| label: "Crawler Type", | ||
| description: "Select the crawling engine:\n- **Headless web browser** - Useful for modern websites with anti-scraping protections and JavaScript rendering. It recognizes common blocking patterns like CAPTCHAs and automatically retries blocked requests through new sessions. However, running web browsers is more expensive as it requires more computing resources and is slower. It is recommended to use at least 8 GB of RAM.\n- **Stealthy web browser** (default) - Another headless web browser with anti-blocking measures enabled. Try this if you encounter bot protection while scraping. For best performance, use with Apify Proxy residential IPs. \n- **Raw HTTP client** - High-performance crawling mode that uses raw HTTP requests to fetch the pages. It is faster and cheaper, but it might not work on all websites.", | ||
| options: [ | ||
| { | ||
| label: "Headless browser (stealthy Firefox+Playwright) - Very reliable, best in avoiding blocking, but might be slow", | ||
| value: "playwright:firefox", | ||
| }, | ||
| { | ||
| label: "Headless browser (Chrome+Playwright) - Reliable, but might be slow", | ||
| value: "playwright:chrome", | ||
| }, | ||
| { | ||
| label: "Raw HTTP client (Cheerio) - Extremely fast, but cannot handle dynamic content", | ||
| value: "cheerio", | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.apify.runActor({ | ||
| $, | ||
| actorId: ACTOR_ID, | ||
| data: { | ||
| crawlerType: this.crawlerType, | ||
| maxCrawlDepth: 0, | ||
| maxCrawlPages: 1, | ||
| maxResults: 1, | ||
| startUrls: [ | ||
| { | ||
| url: this.url, | ||
| }, | ||
| ], | ||
| }, | ||
| const { body } = await gotScraping({ | ||
| url: this.url, | ||
| }); | ||
| $.export("$summary", `Successfully scraped content from ${this.url}`); | ||
| return response; | ||
| return body; | ||
| }, | ||
| }; | ||
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
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.