Prompt

How do I scrape data from a website without an API?

Latest observation

Jul 15, 2026 · OpenAI APIWeb search: off

If a website doesn’t offer an API, you can still collect data by scraping the pages directly. The basic idea is:

  1. Inspect the page source

    • Open the site in your browser.
    • Use Developer Tools → Elements to see the HTML structure.
    • Find the tags/classes/IDs that contain the data you want.
  2. Fetch the page

    • Use a tool like:
      • Python: requests, BeautifulSoup, lxml
      • JavaScript/Node.js: axios, cheerio, playwright, puppeteer
    • Example in Python:
      import requests
      from bs4 import BeautifulSoup
      
      url = "https://example.com/page"
      html = requests.get(url).text
      soup = BeautifulSoup(html, "html.parser")
      
      titles = [el.get_text(strip=True) for el in soup.select(".title")]
      print(titles)
      
  3. Handle dynamic content

    • If the data is loaded by JavaScript after the page loads, requests may not see it.
    • In that case, use a browser automation tool like:
      • Playwright
      • Selenium
      • Puppeteer
    • These load the page like a real browser.
  4. Paginate / navigate

    • If data spans multiple pages, loop through the page numbers or “next” links.
    • Add delays between requests to avoid overloading the site.
  5. Store the data

    • Save to CSV, JSON, a database, etc.
  6. Be careful about legality and site rules

    • Check the site’s Terms of Service and robots.txt.
    • Don’t scrape private, protected, or copyrighted data in ways that violate rules.
    • Rate-limit your requests and identify your crawler if appropriate.

When scraping gets tricky

  • Anti-bot measures: CAPTCHAs, rate limits, login walls.
  • Dynamic rendering: content only appears after JS execution.
  • Hidden data: sometimes data is embedded in scripts or JSON blobs in the HTML.

Good practice

  • Respect robots.txt
  • Use reasonable delays
  • Cache results
  • Handle errors and retries
  • Don’t make too many requests too quickly

If you want, I can show you:

  • a simple Python scraper
  • a JavaScript/Node.js scraper
  • or a Playwright example for JavaScript-heavy sites

Observation history

Unlock observation history

Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.