Prompt
How do I scrape data from a website without an API?
Latest observation
If a website doesn’t offer an API, you can still collect data by scraping the pages directly. The basic idea is:
-
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.
-
Fetch the page
- Use a tool like:
- Python:
requests,BeautifulSoup,lxml - JavaScript/Node.js:
axios,cheerio,playwright,puppeteer
- Python:
- 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)
- Use a tool like:
-
Handle dynamic content
- If the data is loaded by JavaScript after the page loads,
requestsmay not see it. - In that case, use a browser automation tool like:
- Playwright
- Selenium
- Puppeteer
- These load the page like a real browser.
- If the data is loaded by JavaScript after the page loads,
-
Paginate / navigate
- If data spans multiple pages, loop through the page numbers or “next” links.
- Add delays between requests to avoid overloading the site.
-
Store the data
- Save to CSV, JSON, a database, etc.
-
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.