You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: improve crawler type description and options
* feat: add url validation in scrape-single-url action
* feat: implement url validation method and add tests for scrape-single-url action
* chore: update version of scrape-single-url action to 0.0.4
* chore: remove unecesary test file
* chore: lowered scrape-single-url version
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)",
9
-
version: "0.1.3",
10
+
version: "0.1.4",
10
11
annotations: {
11
12
destructiveHint: false,
12
13
openWorldHint: true,
@@ -24,29 +25,50 @@ export default {
24
25
crawlerType: {
25
26
type: "string",
26
27
label: "Crawler Type",
27
-
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.",
28
+
description: "Select the crawling engine:\n- **Adaptive** - Automatically switches between raw HTTP for static pages and a headless browser for dynamic pages to get the maximum performance wherever possible.\n- **Firefox (Headless Browser)** (default) - Headless Firefox with Playwright and anti-blocking measures enabled. Reliable, renders JavaScript content, and best at avoiding blocking, but might be slow. For best performance, use with Apify Proxy residential IPs.\n- **Cheerio (Raw HTTP)** - High-performance crawling mode that uses raw HTTP requests to fetch the pages. Fastest and cheapest, but doesn't render JavaScript content.",
28
29
options: [
29
30
{
30
-
label: "Headless browser (stealthy Firefox+Playwright) - Very reliable, best in avoiding blocking, but might be slow",
31
-
value: "playwright:firefox",
31
+
label: "Adaptive",
32
+
value: "playwright:adaptive",
32
33
},
33
34
{
34
-
label: "Headless browser (Chrome+Playwright) - Reliable, but might be slow",
label: "The crawler automatically switches between raw HTTP for static pages and Chrome browser (via Playwright) for dynamic pages, to get the maximum performance wherever possible.",
43
-
value: "playwright:adaptive",
44
-
},
45
42
],
46
43
default: "playwright:firefox",
47
44
},
48
45
},
46
+
methods: {
47
+
// new URL() accepts hosts with empty labels (e.g. "google..com"), so check explicitly
48
+
validateUrl(url){
49
+
letparsedUrl;
50
+
try{
51
+
parsedUrl=newURL(url);
52
+
}catch{
53
+
thrownewConfigurationError(`Invalid URL "${url}": could not be parsed. Use a valid absolute URL like https://example.com.`);
54
+
}
55
+
56
+
if(![
57
+
"http:",
58
+
"https:",
59
+
].includes(parsedUrl.protocol)){
60
+
thrownewConfigurationError(`Invalid URL "${url}": only http and https protocols are supported. Use a valid absolute URL like https://example.com.`);
0 commit comments