Vanilla JS Scraper avatar
Vanilla JS Scraper
Try for free

No credit card required

View all Actors
Vanilla JS Scraper

Vanilla JS Scraper

Try for free

No credit card required

Scrape the web using familiar JavaScript methods! Crawls websites using raw HTTP requests, parses the HTML with the JSDOM package, and extracts data from the pages using Node.js code. Supports both recursive crawling and lists of URLs. This actor is a non jQuery alternative to CheerioScraper.

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more

1# Set API token
4# Prepare Actor input
5cat > input.json <<'EOF'
7  "requests": [
8    {
9      "url": ""
10    }
11  ],
12  "pseudoUrls": [
13    {
14      "purl": "[(/[\\w-]+)?]"
15    }
16  ],
17  "linkSelector": "a[href]",
18  "pageFunction": "async function pageFunction(context) {\n    const { window, document, crawler, enqueueRequest, request, response, userData, json, body, kvStore, customData } = context;\n\n    const title = document.querySelector('title').textContent\n\n    const responseHeaders = response.headers\n\n    return {\n        title,\n        responseHeaders\n    };\n}",
19  "preNavigationHooks": "// We need to return array of (possibly async) functions here.\n// The functions accept two arguments: the \"crawlingContext\" object\n// and \"requestAsBrowserOptions\" which are passed to the `requestAsBrowser()`\n// function the crawler calls to navigate..\n[\n    async (crawlingContext, requestAsBrowserOptions) => {\n        // ...\n    }\n]",
20  "postNavigationHooks": "// We need to return array of (possibly async) functions here.\n// The functions accept a single argument: the \"crawlingContext\" object.\n[\n    async (crawlingContext) => {\n        // ...\n    },\n]",
21  "proxy": {
22    "useApifyProxy": true
23  },
24  "additionalMimeTypes": [],
25  "customData": {}
29# Run the Actor using an HTTP API
30# See the full API reference at
31curl "$API_TOKEN" \
32  -X POST \
33  -d @input.json \
34  -H 'Content-Type: application/json'
Maintained by Community
Actor metrics
  • 9 monthly users
  • 0 stars
  • 100.0% runs succeeded
  • Created in Mar 2022
  • Modified 8 months ago