Skip to main content

Tell when a page needs a browser: fetch it both ways

Fetch one script-built practice page with request http and with request browser, look for a word it must hold, and compare the two dated answers.

From our run on
  1. "url": "https://quotes.toscrape.com/js/",
  2. "status": 200,
  3. Tags: change deep-thoughts thinking world
  4. Tags: abilities choices
Lesson 17 of 20 8 min read

A page needs a browser when both fetches of it succeed, the content you expect is missing from the plain HTTP answer, and it is there once the page's scripts have run. You find out by fetching the same address both ways and running the same word check on each answer.

By the end of this lesson you will have two dated answers for one practice page, one fetched without scripts and one rendered, and a count you took yourself: how many quotes each answer holds. Until now your script has sent one plain request per page and checked the status and one word, the check from lesson 1. This lesson changes one value in that request and nothing else.

Why a page can come back empty

Some servers send the whole page in their first answer. Others send a frame with a script in it, and the script fetches the real content and writes it into the page after it loads. Google's guide to JavaScript in search describes that second kind as pages "where the initial HTML does not contain the actual content and Google needs to execute JavaScript before being able to see the actual page content that JavaScript generates." A plain request reads only that initial HTML. It never runs the script, so it never sees what the script would have added.

The status code may not warn you. In the saved runs below, the server answered 200 to both requests, the empty one and the full one. The word check is what catches the difference.

Telling the two kinds apart is one step of the larger job the web scraping guide walks through. Here you take that step on one address.

This clip sets the two answers side by side.

When a page needs a browser. 53 s, no sound. The words are on screen, and the captions button shows them at your own text size.
Read the transcript

When a page needs a browser. One address asked for as markdown twice, without and with a browser.

The plain answer is the site title and two links. No quotes. Quotes to Scrape. #. [Quotes to Scrape](https://quotes.toscrape.com/). [Login](https://quotes.toscrape.com/login). 4: lines in the answer. 0: lines that start Tags:.

With a browser, the answer holds a Tags line for each quote. Tags: change deep-thoughts thinking world. Tags: abilities choices. Tags: inspirational life live miracle miracles. Tags: aliteracy books classic humor. 10: lines that start Tags:. 6: of them not drawn here.

Only the pair of answers shows that this page needs a browser. "request": "http": 0 lines. "request": "browser": 10 lines. fields changed between them: 1. 2: answers for one address. 10: more lines with a browser.

Run both fetches on each new kind of page. Where the text turned up: count Tags: in each. http: Stay with http, it is fastest. browser: Note it: this page needs browser. neither: Look at the page again first. This run: browser.

Read the full page. The page is at spider.cloud/learn/course/when-a-page-needs-a-browser.

The practice page

https://quotes.toscrape.com/js/ is a site built for scraping practice. Before you load anything from it, read https://quotes.toscrape.com/robots.txt and confirm the /js/ path is open to you, the way the robots.txt page shows. Only then open the page in your own browser. You see ten quotes, each with its author and a line of tags. Every quote has a Tags: line, so that is your word. A good answer holds it ten times. An answer with none of them has failed the check, and that is all it tells you on its own. It could be the frame without its content, or a page you were never meant to get. Only the second fetch says which.

The page also has a Login link. Leave it alone. This lesson reads what the page shows a visitor who has not signed in.

Change one value

The request field decides how the page is fetched. The API reference says of its values: "http is fastest and runs no JavaScript. browser renders the page." Your lesson 1 request sent http, so send that one first. It reads your key from the SPIDER_API_KEY environment variable and sends a User-Agent that names the client, as identify your crawler explains.

curl -s https://api.spider.cloud/scrape \
  -H "Authorization: Bearer $SPIDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://quotes.toscrape.com/js/", "request": "http", "return_format": "markdown", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"}'

The API answers with a JSON array that holds one object per page, so read the first item. The saved run of that request, made on 2026-11-20 at 20:42 UTC, came back with status 200. Below is an excerpt of that first item: the four fields this lesson reads.

{
  "url": "https://quotes.toscrape.com/js/",
  "status": 200,
  "error": null,
  "content": "Quotes to Scrape\n#\n[Quotes to Scrape](https://quotes.toscrape.com/)\n[Login](https://quotes.toscrape.com/login)"
}

That is the site title and two links. The word Tags: appears zero times, so by the lesson 1 check this page failed, even with a 200 beside it.

When you send it yourself, read that answer before you send anything else. Look at status and content. If the status is 403 or 429, or the content is a sign-in form or a challenge page, the site has said no. Stop there and do not send the second request. For a 429, the Retry-After page covers how long to wait before you ask again. If the answer is a 200 page, count the word, then pause a few seconds before the second load, as how many requests per second to send explains. A page that runs scripts gets the same pace as any other.

The second answer

The second request differs from the first only in the request field.

curl -s https://api.spider.cloud/scrape \
  -H "Authorization: Bearer $SPIDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://quotes.toscrape.com/js/", "request": "browser", "return_format": "markdown", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"}'

Read this answer the same way, with the same stop rule, before you count. Its saved run went out on 2026-11-20 a few seconds after the first, and it also came back with status 200 and a null error. Its url field reads https://quotes.toscrape.com/js/, the address you asked for. Its content starts with the same four lines and goes on, one line of quote text and author, then one line of tags, for each quote. Below are the four lines, the first quote line as it came back, and every tags line, in order. The other nine quote lines are left out, down to the last, by Steve Martin. The site prints curly quote marks, and this copy shows them as straight ones.

Quotes to Scrape
#
[Quotes to Scrape](https://quotes.toscrape.com/)
[Login](https://quotes.toscrape.com/login)
"The world as we have created it is a process of our thinking. It cannot be changed without changing our thinking."by Albert Einstein
Tags: change deep-thoughts thinking world
Tags: abilities choices
Tags: inspirational life live miracle miracles
Tags: aliteracy books classic humor
Tags: be-yourself inspirational
Tags: adulthood success value
Tags: life love
Tags: edison failure inspirational paraphrased
Tags: misattributed-eleanor-roosevelt
Tags: humor obvious simile

The full answer has ten Tags: lines, one for each quote you saw in your own browser, and the quote text the plain answer lacked. The check passes. Now you have two successful answers for the same address, and only the rendered one holds the content. That pair, not the empty answer alone, is what tells you this page needs a browser.

A third request on the same day, at 20:44 UTC, left the request field out, and it returned the same four-line shell as http.

What to do with the result

Write the result down next to the address. With return_format set to markdown, this page needs request: "browser". The static vs rendered page reads the raw body of the same address and finds all ten records in a script, so try that before you render a page of your own. That note is about this page. A site can serve some pages whole and build others with scripts, so run the two-way fetch on each new kind of page before you decide. Where the plain answer already passes the word check, stay with http, which the reference names as the fastest of the values.

The comparison settles something only when one answer holds the word. If both counts are zero, it does not tell you which value to use. The word may be one the page never shows a visitor who is signed out, or one you misread, so look at the page in your own browser again before you choose.

A rendered page can show more than the plain one, and some of it may be about people: names, emails, profile details. Leave that out of what you save. The European Union section of our robots.txt and law survey explains why published personal data is still personal data.

Try it yourself

Pick a page on a site meant for practice, or a documentation page you read often, and read the site's robots.txt first, the way the robots.txt page shows. Choose the word the page must hold by looking at it in your own browser. Then send the two requests above with your address in url, the http one first, reading it and pausing before the second, and stopping at either one if the site says no. Count that word in each content field. You are done when you can write one line that names the page, the count from http, the count from browser, and either the value you will use for it or, if both counts are zero, that the test did not settle it.

Do this, avoid this

Do this

  • Pick the word to look for before you send either request, by reading the page in your own browser.
  • Change only the request field between the two calls, so the field is the one thing that differs.
  • Count the word in each answer and write both counts beside the page address.
  • Stay with http for any page where the plain answer already holds the word.

Avoid this

  • Reading the status field to decide, when both answers can carry the same 200.
  • Deciding for a whole site from one page.
  • Going on after either answer is a sign-in page, a challenge, a 403 or a 429. The site has said no, so stop.
  • Keeping names, emails or other personal data a rendered page shows. Leave it out of what you save.

Next

The rendered answer here came back as finished text. The next lesson asks how a program opens a session in the cloud browser and loads a page itself, so it can do more than read the result. The cloud browser reference describes that connection.

Sources

  1. Google Search Central, Understand the JavaScript SEO basics Read
  2. Spider OpenAPI file, the request field of /scrape Read

Run this on a page you care about

The playground sends the request this page describes and shows you the response. Keyless runs work without an account and are rate limited.