SerpBase
Back to Blog

Google Search HTML API: Get the Raw Results Page with format=raw

Add format=raw and a Google search returns the results page itself as HTML, with scripts removed. Tested sizes for mobile and desktop, the headers, and a parsing script.

November 28, 2026
By SerpBase Team3 min read

Short answer: add "format":"raw" to a /google/search request and the answer is the Google results page itself, as HTML. Same endpoint, same parameters, same 1 credit. You parse it yourself.

Use it when you already have a parser for Google's markup, when you want a module the JSON answer does not carry, or when you need to keep a copy of the page as evidence of what was shown.

The request

curl -X POST 'https://api.serpbase.dev/google/search' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{"q":"coffee shops","gl":"us","hl":"en","format":"raw"}' \
  -o serp.html -D headers.txt

What comes back

We ran these on 28 November 2026 for coffee shops, gl=us, hl=en.

Default device (mobile). Content-Type: text/html; charset=utf-8, 242,134 characters, page title coffee shops - Google Search. The document had no <script> tags, 19 <style> blocks and 66 links.

"device":"desktop". 284,179 characters, 21 <style> blocks and 60 links. Same title.

There is no JSON envelope around a raw answer, so there is no status or request_id in the body. One thing moves to a header:

HeaderWhat it holds
Content-Typetext/html; charset=utf-8 on success
X-Search-URLThe Google address that answered the search. In our test: https://www.google.com/search?q=coffee+shops&oq=coffee+shops&hl=en&gl=us&sourceid=chrome&ie=UTF-8

Python: save the page and pull the titles

import requests
from html.parser import HTMLParser

r = requests.post(
    "https://api.serpbase.dev/google/search",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={"q": "coffee shops", "gl": "us", "hl": "en",
          "format": "raw", "device": "desktop"},
    timeout=60,
)

if not r.headers["Content-Type"].startswith("text/html"):
    print("failed:", r.json().get("error"))
    raise SystemExit

open("serp.html", "w", encoding="utf-8").write(r.text)
print("fetched from", r.headers.get("X-Search-URL"))

class Titles(HTMLParser):
    def __init__(self):
        super().__init__(); self.on = False; self.out = []
    def handle_starttag(self, tag, attrs):
        if tag == "h3": self.on = True; self.out.append("")
    def handle_endtag(self, tag):
        if tag == "h3": self.on = False
    def handle_data(self, data):
        if self.on: self.out[-1] += data

p = Titles(); p.feed(r.text)
print(p.out)

On our desktop sample this printed 10 headings: eight result titles plus More places and Map from the local pack.

Things that trip people up

  • Check Content-Type before you parse. The docs state that a failed request keeps the JSON error envelope whatever format you asked for. If the type is application/json, read status and error instead of feeding the body to an HTML parser.
  • The mobile and desktop pages use different markup. In our mobile sample only two <h3> elements existed in the whole page; result titles sit in other elements there. Ask for "device":"desktop" if your parser was written against the desktop layout.
  • The scripts are stripped. Anything Google fills in with JavaScript after load is not in the document. What you get is the page as first delivered.
  • Not every link is a final address. In our samples 18 of the 66 links on the mobile page and 16 of 60 on the desktop page were Google's relative /goto?url= wrappers. Prefix them with https://www.google.com and pass them to the free link resolver, or use the JSON answer when you need clean links.
  • Raw is for Google web search only. Other endpoints offer json and markdown.
  • It is a big answer. A quarter of a megabyte per page adds up; store compressed if you keep them.

Raw, Markdown or JSON?

You wantAsk for
Fields you can read straight away: organic, people_also_ask, ai_overviewjson (the default)
Text to paste into a promptmarkdown
The page itself, for your own parser or for the recordraw

Cost and limits

A raw page costs 1 credit, the same as the JSON answer; failed requests are not charged. Credits cost $0.25–$0.50 per 1,000 depending on the plan, and new accounts get 500 free credits without a card.