🚀 New: ChatGPT Scraper API — Run prompts & get structured JSON responses

Add Your Heading Text Here

How to Scrape ChatGPT with Python (Step-by-Step Guide)

How to scrape chatgpt with python

Table of Contents

ChatGPT has become one of the most used AI platforms on the internet. Developers, researchers, and marketers are increasingly interested in extracting ChatGPT responses at scale. Whether to track what ChatGPT says about their brand, build AI monitoring pipelines, or power LLM-based research workflows.

The problem? Scraping ChatGPT manually is painful. It requires browser automation, anti-bot bypass logic, session management, and handling dynamic content, all of which break frequently as OpenAI updates its platform.

In this guide, you will learn how to scrape ChatGPT with Python and Scrapingdog’s ChatGPT Scraper API, a dedicated solution that handles all the complexity for you, so you can extract ChatGPT responses with a single API call.

Why Scrape ChatGPT?

Most people use ChatGPT interactively, but querying it programmatically at scale unlocks real business value. Here’s why developers and companies do it:

why scrape chatgpt workflow

  • Brand & AI Visibility Monitoring — Many users ask ChatGPT for recommendations instead of Googling. Scraping lets you track whether ChatGPT mentions your brand or your competitors.
  • AI Response Research — Study LLM behavior, bias, or hallucinations by collecting responses to hundreds of prompts systematically.
  • Competitor Intelligence — You can query ChatGPT about competitor products, pricing, and features, and combine it with structured product data from APIs like Amazon Scraper API to validate what ChatGPT recommends against real-time pricing and listings.
  • Training Data & Benchmarking — Use ChatGPT responses as reference data when fine-tuning or benchmarking your own models.
  • Automated Content Pipelines — Feed ChatGPT responses into enrichment or summarization workflows without manual copy-pasting.

What Is Scrapingdog’s ChatGPT Scraper API?

Scrapingdog has recently launched a dedicated ChatGPT Scraper API . You just have to pass a query/prompt to the API and in return you will get clean, structured JSON, without dealing with any of the underlying browser automation or anti-bot complexity.

Key features:

  • Submit any prompt and get ChatGPT’s response back as structured data
  • No browser automation required .
  • Handles Cloudflare restrictions.
  • Supports concurrent requests for high-volume workflows
  • Returns clean JSON output ready for downstream processing
  • Python-friendly with simple requests integration

This means you can focus entirely on your data pipeline, not on fighting OpenAI’s anti-scraping stack.

Prerequisites

Before you start, make sure you have:

				
					pip install requests
				
			

That’s it. No Playwright, no Selenium, no proxy configuration required.

Scraping ChatGPT with Python

Let’s start with the simplest possible example by sending a single prompt to ChatGPT and printing the response.

We will start from the dashboard.

chatgpt scraper dashboard

Once you pass the query/prompt in the scraper you will get a ready to use python code.

				
					import requests

api_key = "your-api-key"
url = "https://api.scrapingdog.com/chatgpt"

params = {
    "api_key": api_key,
    "prompt": "What are the best web scraping tools in 2026?"
}

response = requests.get(url, params=params)

if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print(f"Request failed with status code: {response.status_code}")
				
			

This code sends a prompt to Scrapingdog’s ChatGPT Scraper API and prints the response.

Here’s the flow:

  1. Sets up credentials — your API key and the endpoint URL.
  2. Defines params — the API key and the prompt you want to send to ChatGPT.
  3. Makes a GET request — sends the prompt to the API via requests.get().
  4. Handles the response — if successful (status 200), parses and prints the JSON response; otherwise prints the error code.

Once you run this code you get this JSON response.

json response

The response has two main fields:

1. conversation A structured array containing the full exchange — your prompt (user) and ChatGPT’s reply (assistant). The assistant’s response is broken down into typed content blocks:

  • paragraph — introductory or descriptive text
  • heading — section titles (e.g., “AI-Powered Scraping Tools”)
  • bullet_list — tools listed under each category with their strengths and best-use cases

2. markdown The exact same response, but as a raw markdown string — useful if you want to render it directly in a UI or blog without parsing the structured JSON.

Parsing the API Response

The response contains structured content blocks inside conversation[-1]["response"]. Here’s how to handle each block type — paragraphheading, and bullet_list and extract clean text from them.

				
					import requests

API_KEY = "your_scrapingdog_api_key"
ENDPOINT = "https://api.scrapingdog.com/chatgpt"


def parse_response_blocks(blocks: list) -> str:
    """
    Parse the assistant's structured response blocks into plain text.
    Handles: paragraph, heading, bullet_list
    """
    lines = []

    for block in blocks:
        block_type = block.get("type")

        if block_type == "paragraph":
            lines.append(block.get("text", ""))
            lines.append("")  # blank line after paragraph

        elif block_type == "heading":
            level = block.get("level", 2)
            prefix = "#" * level
            lines.append(f"{prefix} {block.get('text', '')}")
            lines.append("")

        elif block_type == "bullet_list":
            for item in block.get("items", []):
                heading = item.get("heading", "")
                text = item.get("text", "")
                # Skip duplicate sub-items (heading-only entries like "Strengths:", "Best for:")
                if text and heading not in ("Strengths:", "Best for:"):
                    lines.append(f"- **{heading}**: {text}" if heading else f"- {text}")
            lines.append("")

    return "\n".join(lines)


def query_chatgpt(prompt: str) -> dict:
    """
    Query ChatGPT via Scrapingdog and return a parsed result dict.
    """
    response = requests.get(
        ENDPOINT,
        params={"api_key": API_KEY, "prompt": prompt},
        timeout=90
    )
    response.raise_for_status()
    data = response.json()

    # Extract the assistant turn (always the last in the conversation)
    assistant_turn = data["conversation"][-1]
    response_blocks = assistant_turn.get("response", [])

    return {
        "prompt": data["conversation"][0]["message"],
        "markdown": data.get("markdown", ""),         # pre-rendered markdown string
        "parsed_text": parse_response_blocks(response_blocks),  # custom parsed text
        "raw_blocks": response_blocks                 # original structured blocks
    }


if __name__ == "__main__":
    result = query_chatgpt("What are the best web scraping tools in 2026?")

    print("Prompt:", result["prompt"])
    print("\n--- Parsed Text ---")
    print(result["parsed_text"])

    print("\n--- Markdown (pre-rendered) ---")
    print(result["markdown"][:500], "...")  # preview first 500 chars
				
			

Extracting Specific Block Types

If you only need specific content, for example just the headings to build a table of contents or just the bullet points, you can filter the blocks directly:

				
					def extract_headings(blocks: list) -> list[str]:
    """Return all heading texts from the response."""
    return [b["text"] for b in blocks if b.get("type") == "heading"]


def extract_bullet_items(blocks: list) -> list[dict]:
    """Return all bullet list items across all bullet_list blocks."""
    items = []
    for block in blocks:
        if block.get("type") == "bullet_list":
            for item in block.get("items", []):
                # Filter out sub-label duplicates
                if item.get("text") and item.get("heading") not in ("Strengths:", "Best for:"):
                    items.append(item)
    return items


# Usage
result = query_chatgpt("What are the best web scraping tools in 2026?")
blocks = result["raw_blocks"]

print("Sections:", extract_headings(blocks))
print("Tools mentioned:", [i["heading"] for i in extract_bullet_items(blocks)])
				
			

Real-World Use Cases

1. Brand Monitoring on ChatGPT- Track what ChatGPT says about your company across different question angles:

				
					brand_prompts = [
    "What is Scrapingdog?",
    "What are the best web scraping APIs?",
    "Is Scrapingdog a good tool for web scraping?",
    "What alternatives are there to Scrapingdog?",
    "What do people say about Scrapingdog?"
]

results = batch_query_chatgpt(brand_prompts)
				
			

Schedule this to run weekly or daily and compare the markdown responses over time to see how your ChatGPT visibility changes.

 2. Competitor Research

				
					competitor_prompts = [
    "Compare Scrapingdog vs Brightdata for web scraping",
    "What is the cheapest web scraping API in 2025?",
    "Which scraping API has the best Google SERP support?",
    "What are developers saying about Apify vs Scrapingdog?"
]

competitor_data = batch_query_chatgpt(competitor_prompts)
				
			

3. SEO & AI Visibility Research– As ChatGPT increasingly influences user decisions, knowing whether your content surfaces in its responses is critical. Pair this with Google Search Result Scraper to compare your rankings across both Google and ChatGPT simultaneously:

				
					seo_prompts = [
    "Best Python tutorial sites in 2025",
    "Where can I learn web scraping online?",
    "Top blogs about Python and data engineering",
]

seo_visibility = batch_query_chatgpt(seo_prompts)

# Check if your brand appears in the markdown response
your_brand = "scrapingdog"
for r in seo_visibility:
    mentioned = your_brand.lower() in r["markdown"].lower()
    print(f"Prompt: {r['prompt'][:50]}")
    print(f"Mentioned: {'✅ YES' if mentioned else '❌ NO'}\n")
				
			

Note: You should also use the Google News Scraping API to monitor your brand's mentions on the Internet.

Key Takeaways:

  • DIY scraping of ChatGPT is fragile — Cloudflare protection, streaming responses, and frequent UI changes make browser automation an unreliable approach for production use.
  • The API returns structured blocks, not plain text — responses come as typed content blocks (paragraphheadingbullet_list) plus a pre-rendered markdown field; parse accordingly.
  • Use markdown for simplicity, raw_blocks for control — if you just need the text, grab data["markdown"]; if you need to extract headings or bullet items individually, iterate over conversation[-1]["response"].
  • Brand and AI visibility monitoring is the killer use case — as users shift from Google to ChatGPT for recommendations, tracking whether ChatGPT mentions your product is becoming as important as tracking your Google rankings.

Conclusion

Scraping ChatGPT manually is possible but fragile, browser automation breaks with every OpenAI update, session management is tedious, and handling streaming responses adds significant complexity.

Scrapingdog’s ChatGPT Scraper API eliminates all of that. With a single API call, you get ChatGPT’s response in clean JSON, ready to process in Python. Whether you’re building a brand monitoring pipeline, running AI research at scale, or tracking how ChatGPT talks about your product, this approach is production-ready from day one.

Frequently Asked Questions

Is scraping ChatGPT legal?

In this article, whatever we scraped was available publicly. Scrapingdog does not scrape anything that is behind a login screen.

Why not use the OpenAI API directly?

The OpenAI API generates responses; it doesn’t reflect what ChatGPT’s web interface says with web search enabled. Plus, scraping ChatGPT with Scrapingdog is almost 15x cheaper than using the API.

Will the API break when OpenAI updates its UI?

No. Scrapingdog maintains the underlying infrastructure, so UI changes on OpenAI’s end are handled on their side; your code stays untouched.

Can I use this with async Python?

Yes. Wrap the requests calls with httpx and asyncio for concurrent scraping.

What does the API return?

conversation array (structured content blocks per turn) and a markdown field (full response as a ready-to-use Markdown string). See Scrapingdog’s docs for the full schema.

Web Scraping with Scrapingdog

Scrape the web without the hassle of getting blocked

Recent Blogs

How to scrape chatgpt with python

How to Scrape ChatGPT with Python (Step-by-Step Guide)

Learn how to scrape ChatGPT responses with Python using Scrapingdog's ChatGPT Scraper API. No browser automation needed, get structured JSON output in minutes.
Web Scraping Google Lens

How to Scrape Google Lens with Python (2026 Guide)

Learn how to scrape Google Lens using Python and Scrapingdog's API. Extract visual search results, image matches, and source data in a few lines of code.