Netweir 0.4.0 is on PyPI. There are 235 commits in it since 0.3.1, more than in any release before, and most of them are about the pages that make you work: the ones that want a click, a login or a phone before they’ll show you anything.

pip install -U netweir

You know the five lines. Accept the cookies, click “Load more”, wait for the fortieth product, and only then start reading. Every spider that rendered pages had some version of them, and a rules spider couldn’t have them at all.

Now the request carries them, as steps, and Chrome does them before your callback sees the page:

from netweir import steps

yield netweir.Request(
    "https://shop.example/catalogue",
    steps=[
        steps.click("#accept-cookies", timeout=3, on_error="continue"),
        steps.click("button.load-more"),
        steps.wait_for("li.product:nth-child(40)"),
    ],
)

Each step is a plain dict, so a step list can live in a JSON file, survive a checkpoint, or travel through a shared queue to another machine. You can type into a field one key at a time, with the pauses a person leaves; scroll a feed until it stops growing; pick from a dropdown; reach into an iframe; take a screenshot; or hand the page to a function of your own. netweir.Follow(..., steps=[...]) gives steps to a rules spider, and the browser_steps setting gives them to every page a crawl opens in Chrome.

Coming from Zyte API’s actions, scrapy-playwright’s page methods or Scrapling’s page_action? The steps guide has a table that maps each one across.

The data was in the page’s own API calls

Plenty of JavaScript pages are a thin shell around a JSON API. The page fetches the list, then its script turns it into HTML for you to pick apart. Why not take the list?

async with page.expect_response("**/api/products*") as info:
    await page.click("button.load-more")
response = await info.value
products = (await response.json())["products"]

page.route() answers, changes or drops a page’s requests before they leave Chrome, and page.block() stops it fetching the images, fonts and video you were never going to look at. In a crawl, browser_block=("image", "font", "media") does that for every page. Frames and workers from other sites go through the same routes, so a frame from another site doesn’t get round them.

Hover, scroll, popups and downloads

Chrome pages learned a lot more of what a hand on a mouse does: hover, scroll (an element into view, or a feed to the bottom, round after round), pick from a <select>, tick a box, choose a file, and work inside frames, cross-site ones included. It’s real mouse and wheel input, a notch at a time, not a script pretending.

An alert() used to leave a page waiting for nobody. Now every dialog gets answered, half a second to a second and a half after it opens, because a page can time confirm() and nobody clicks OK in a millisecond. page.on_dialog() lets you answer them yourself.

A link that opens a new tab is caught with expect_popup(). A file the site sends as an attachment, with expect_download():

async with page.expect_download("**/*.csv") as info:
    await page.click("a.export")
download = await info.value
await download.save_as("prices.csv")

Nothing lands in your Downloads folder. And a download that nobody’s listening for is cancelled as it starts, so a stray link to a 4 GB file can’t fill your disk while you’re looking the other way.

A phone in Berlin, the same phone everywhere it’s asked

A site that wants to know who you are doesn’t ask once. It reads navigator.language, then checks it against Intl, against the Accept-Language of every request, against what a worker says and what a frame from another site says. Set one of those and leave the rest, and the disagreement is what gives you away.

async with netweir.browser(environment={"device": "Galaxy S23", "locale": "de-DE", "timezone_id": "Europe/Berlin"}) as browser:
    page = await browser.new_page()

Netweir sets each one through Chrome itself, in the page, in its frames and in its workers, so they all tell the same story. Viewport, screen, colour scheme, geolocation, permissions, extra headers and init scripts are there too, mostly under the names Playwright uses, and you can set them for one page, a context or the whole browser. A crawl takes the lot as one setting, browser_environment. And when Chrome gets past a block and hands the site’s cookies to the HTTP client, the client goes on with the same language, user agent and client hints, so the site sees one visitor rather than two.

A few things Chrome won’t let anyone change, such as a worker’s navigator.platform. A page’s environment lists them rather than pretending.

Your cookies, where you can get at them

Some logins need a real browser: a form built by script, a challenge, a code from your phone. Do that part in Chrome, then crawl at HTTP speed with the session it gave you:

cookies = await page.cookies()

async with netweir.Client() as client:
    client.cookies.add(cookies)
    orders = await client.get("https://shop.example/orders")
    client.storage_state("state.json")

Next week, netweir.Client(storage_state="state.json") picks up where you left off. That’s Playwright’s storage state format, so a file saved by either loads in the other. We write it readable by you alone, since whoever holds it is logged in as you.

In a crawl, Request(cookies=...) works as it does in Scrapy, and meta={"cookiejar": "ada"} keeps Ada’s session apart from Bob’s in the same crawl. Apart all the way through, too: each jar is its own to the duplicate filter, the cache and deltafetch, so Bob never gets Ada’s page back from the cache. A checkpoint saves the jars as it goes, and a resumed crawl is still logged in.

Timeouts, redirects and logins, request by request

What you’d reach for in requests or httpx is here under the same names: params, auth, timeout, allow_redirects, max_redirects and verify.

page = netweir.get("https://example.com/search", params={"q": "rust", "page": 2}, timeout=10)

A crawl’s Request takes them as fields. Scrapy’s download_timeout, dont_redirect and http_user meta keys work too, and retry_http_codes says which statuses deserve another go. None of it changes how the request looks. We recorded where Chrome 155 and Firefox 158 put an Authorization header (Chrome after Host and Connection, Firefox just before Connection), and that’s where Netweir puts it.

XML, read as XML

The URL in an RSS item lives in its <link>. Parse the feed as HTML and that URL vanishes, because HTML’s <link> never holds anything. A page served as XML is now parsed as XML:

page = netweir.get("https://example.com/feed.rss")
page.xpath("//item/link/text()").getall()

Namespaces work the way they do in parsel, with namespaces=, register_namespace() and remove_namespaces(), and a prefix you forgot to bind is an error instead of a query that quietly finds nothing. Scrapy’s XMLFeedSpider and CSVFeedSpider came along as well. On a feed of 50,000 items, the default reader takes about a quarter of the time Scrapy’s does.

The rest of your Scrapy project

0.3.1 brought middlewares and signals across. Most of what was left has followed:

  • Item loaders, as netweir.loader.ItemLoader, with no extra packages to install. All but one of itemloaders’ own tests pass against it, and that one is about installing parsel.
  • netweir.files() and netweir.images(), which read file_urls and image_urls as Scrapy’s pipelines do and download through the crawl, politeness and all.
  • Spider middlewares, a downloader middleware’s process_request answering with a page of its own, and a good deal more of Scrapy’s signals.
  • startproject, genspider, list, parse and check, which runs the contracts in your docstrings against live pages.

The article, without the page around it

Most of a news page isn’t the news. Menus, a cookie banner, share buttons, a box of related stories, a few hundred comments. Ask for the part you came for:

page.markdown(main_only=True)   # the story as Markdown
page.article().byline           # who wrote it

page.article() adds the title, date, lead image and language, and clean_text() gives plain text. It all runs in Rust, in 3 to 9 ms on a 1 MB page. Found one product card and want the other 39? find_similar() gives you the elements shaped like it. There’s jmespath() for JSON, and Beautiful Soup’s editing (decompose, unwrap, replace_with and the rest) for tidying a page before you read it.

A long crawl that tells you how it’s going

A six-hour crawl used to say nothing until the end. Now it logs a line every minute: pages and items with their rates, errors, what’s queued and in flight, bytes received. Set metrics_port and Prometheus can read the same numbers at /metrics while it runs, or anything else at /stats.json. spider.stats is live in your callbacks, with Scrapy’s inc_value and friends.

Also

  • "chrome" and "firefox" now send what Chrome 155 and Firefox 158 send, recorded from the real browsers, and netweir install chrome fetches Chrome for Testing 155. The 154 and 156 profiles stay for anyone still on them.
  • A crawl delay is now the gap the site sees. Before, a request stuck behind a slow handshake could be overtaken by the next one: with a 300 ms delay and a 400 ms handshake, the second request arrived first. Netweir now holds the next request until the connection is made, then waits the delay.
  • A checkpoint commit that failed, on a full disk say, could leave a resumed crawl writing items twice. Its writes are now kept and go in the next commit, and a disk that stays full stops the crawl with an error that says so instead of eating memory.
  • page.form() and Request.from_form() take files= for a form’s file inputs.
  • On free-threaded Python 3.14, eight threads querying one shared page went from 10,000 css().get() calls a second each to 60,000.
  • A script killed before it closed Chrome no longer leaves Chrome running, and a long list of Windows fixes went in, from a Chrome that died unnoticed to a cancelled netweir serve job that lost its last items.

What’s next

Pages that know what they are. A product page, a list of products, a job posting: we’d like Netweir to pull those out on its own, from the page’s structured data and its layout, without you writing a selector. After that, extraction by a language model into a schema you give it, with your own key, and an MCP server.

On the browser side, the gaps I know about are keyboard and mouse ones (modifier keys, dragging, back and forward) and locators by text and role. Then saving a page as a PDF, tracing, and replaying a HAR file through routes. Firefox and WebKit engines are on the list, though only once they can be driven without announcing it. HTTP/3 too, when it can go out looking exactly like the browser it claims to be.

Every change is on the changelog. Issues and fixes are welcome on GitHub.