Skip to content
//Web Scraper – Any Website to Clean Data example\\

Python tutorial without media, 5 pages

Same crawl with images and CSS downloads turned off.

Updated December 5, 2026

What each setting does

The input this example runs Web Scraper – Any Website to Clean Data with. “Try this input” opens it in the console, where you can run it as-is or change any field first.

Start URLs startUrls

https://docs.python.org/3/tutorial/

Pages to scrape. Put your own URL here: each page comes back as one row in the format chosen under What do you want back?

Max pages per run maxPagesPerCrawl

5

Stop after loading this many pages. The real count can be slightly higher. 0 means no limit.

Default: 0 → this example uses 5

Page function pageFunction

// Runs on every page and returns its title and main text. // To scrape another site, change the Start URL. To extract other data, edit this // function; the README lists everything on the "context" object. async function pageFunction(context) { // jQuery reads the page (needs "Inject jQuery", …

Used when What do you want back? is Page function (advanced). Async JavaScript function run on each page's HTML (after scripts with Use Chrome) in a plain DOM, not in Chrome: no context.page, no browser APIs such as performance or fetch. Read the page with context.jQuery or document. Return an object or an array of…

Link selector linkSelector

a[href]

CSS selector for the links to follow (anchor elements with an href, e.g. a[href]). Glob patterns and Pseudo-URLs filter which of them are queued. Leave empty to ignore page links.

Glob Patterns globs

{"glob":"https://docs.python.org/3/tutorial/*"}

Glob patterns to match links in the page that you want to enqueue. Combine with Link selector to tell the scraper where to find links. Omitting the Glob patterns will cause the scraper to enqueue all links matched by the Link selector.

Exclude Glob Patterns excludes

{"glob":"/**/*.{png,jpg,jpeg,pdf}"}

Glob patterns to match links in the page that you want to exclude from being enqueued.

Respect the robots.txt file respectRobotsTxtFile

Yes

If enabled, the crawler will consult the robots.txt file for the target website before crawling each page. At the moment, the crawler does not use any specific user agent identifier. The crawl-delay directive is also not supported yet.

Default: No → this example uses Yes

Navigation waits until waitUntil

domcontentloaded

A JSON array of page events Chrome waits for before the page counts as loaded and the page function runs. Available events are domcontentloaded, load, networkidle2 and networkidle0. The default domcontentloaded takes the page as soon as its HTML and scripts are parsed, which is fastest and keeps Chrome usage low; use…

Download media files downloadMedia

No

When Use Chrome is on and this is enabled, the browser downloads images, fonts, video, and audio. Off by default: those subresources are blocked, which keeps the Chrome usage you pay low. Turn it on only when your page function or hooks need them. The HTTP path downloads the document only.

Download CSS files downloadCss

No

When Use Chrome is on and this is enabled, the browser downloads stylesheets. When it is disabled, stylesheets are blocked; that saves little and can stop infinite-scroll pages from loading more items, so it is on by default. The HTTP path downloads the document only.

Default: Yes → this example uses No

Pre-navigation hooks preNavigationHooks

// We need to return array of (possibly async) functions here. // The functions accept two arguments: the "crawlingContext" object // and "gotoOptions". [ async (crawlingContext, gotoOptions) => { // ... }, ]

Async functions run before navigation, with crawlingContext and gotoOptions. In Chrome, crawlingContext.page has only title, url, content, evaluate, $eval, $$eval, click, waitForSelector, setExtraHTTPHeaders, addInitScript and setViewportSize: no page.on, page.route or waitForResponse. To keep XHR/fetch responses,…

Post-navigation hooks postNavigationHooks

// We need to return array of (possibly async) functions here. // The functions accept a single argument: the "crawlingContext" object. [ async (crawlingContext) => { // ... }, ]

Async functions run after navigation, before the page's HTML is taken for the page function. In Chrome, crawlingContext.page has the same methods as in pre-navigation hooks (evaluate, waitForSelector, click and the others; no page.on). To hand data to the page function, write it into the document with page.evaluate…

Run mode runMode

PRODUCTION

PRODUCTION applies page timeouts and runs requests concurrently. DEVELOPMENT runs one request at a time and does not apply page timeouts.

Custom data customData

{}

A custom JSON object that is passed to Page function as context.customData. This setting is useful when invoking the scraper via API, in order to pass some arbitrary parameters to your code.

.json
{
  "startUrls": [
    {
      "url": "https://docs.python.org/3/tutorial/"
    }
  ],
  "pageFunction": "// Runs on every page and returns its title and main text.\n// To scrape another site, change the Start URL. To extract other data, edit this\n// function; the README lists everything on the \"context\" object.\nasync function pageFunction(context) {\n    // jQuery reads the page (needs \"Inject jQuery\", which is on by default).\n    const $ = context.jQuery;\n    const pageTitle = $('title').first().text().replace(/\\s+/g, ' ').trim();\n\n    // The main content: the page's <main> or role=\"main\" area, a single <article>,\n    // a common content container, or else the whole body.\n    let main = $('main, [role=\"main\"]').first();\n    if (!main.length && $('article').length === 1) main = $('article');\n    if (!main.length) main = $('#content, #main, #main-content, .main-content, .post-content, .entry-content').first();\n    if (!main.length) main = $('body');\n\n    // Work on a copy without menus, headers, footers, sidebars, forms and scripts.\n    main = main.clone();\n    main.find('nav, header, footer, aside, form, script, style, noscript, template, svg, iframe, button, '\n        + '[role=\"navigation\"], [role=\"banner\"], [role=\"contentinfo\"], [role=\"search\"], [aria-hidden=\"true\"], .headerlink').remove();\n    // Mark the end of each block element, so paragraphs become separate lines.\n    const BREAK = '\\uE000';\n    main.find('p, div, section, li, h1, h2, h3, h4, h5, h6, pre, blockquote, tr, dt, dd, br').after(BREAK);\n    const text = main.text()\n        .split(BREAK)\n        .map((line) => line.replace(/\\s+/g, ' ').trim())\n        .filter(Boolean)\n        .join('\\n');\n\n    context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);\n\n    // Each returned object becomes one row of the dataset.\n    return {\n        url: context.request.url,\n        pageTitle,\n        text,\n    };\n}",
  "linkSelector": "a[href]",
  "globs": [
    {
      "glob": "https://docs.python.org/3/tutorial/*"
    }
  ],
  "excludes": [
    {
      "glob": "/**/*.{png,jpg,jpeg,pdf}"
    }
  ],
  "pseudoUrls": [],
  "respectRobotsTxtFile": true,
  "waitUntil": [
    "domcontentloaded"
  ],
  "preNavigationHooks": "// We need to return array of (possibly async) functions here.\n// The functions accept two arguments: the \"crawlingContext\" object\n// and \"gotoOptions\".\n[\n    async (crawlingContext, gotoOptions) => {\n        // ...\n    },\n]\n",
  "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]",
  "runMode": "PRODUCTION",
  "customData": {},
  "maxPagesPerCrawl": 5,
  "downloadMedia": false,
  "downloadCss": false
}

What it costs

You pay for the events the actor reports, such as each result or page it produces. Platform usage is included, except when a run renders pages in a browser: such runs also pay their platform usage (compute, browser, proxy) at your plan's rates.

  • Resultfrom $0.00046One record with data returned by your page function and saved to the dataset.
  • Residential proxy MBfrom $0.00035One started megabyte (1,000,000 bytes) of residential proxy traffic that a run without Chrome used above the 0.5 MB included with each saved result, such as a large PDF or file. Light pages and Chrome runs are not charged for it.

Full pricing

When to use this example

From the Web Scraper – Any Website to Clean Data readme:

Known limit

The page function reads the captured HTML, not the live browser; browser actions go in the navigation hooks.

Other ways to run Web Scraper – Any Website to Clean Data

All examples of Web Scraper – Any Website to Clean Data

About Web Scraper – Any Website to Clean Data

Scrape any website without setup: paste links and get clean text, HTML or your own fields back. Protected pages switch to a real browser and a local IP on their own. Pay per saved page.

Price:
From $0.46 / 1,000 results
Developer:
Querystone

Web Scraper – Any Website to Clean Data pageOutput fieldsPricing

Related actors

//From the blog\\

Latest articles

All articles

The internet is full of data.
Start owning yours.

Scrape.ly gives you the infrastructure, the tooling, and the team to extract, process, and operationalize web data at any scale. Setup takes minutes.

No credit card. No setup calls.