Prompt

How do I extract table data from websites that only show it in HTML?

Technology / API Platforms1 observationLast seen Oct 4, 2026

Latest observation

Oct 4, 2026OpenAI APIWeb search: off

To extract table data from websites that present it in HTML, you usually have a few options depending on how the page is built.

1) Check if the table is directly in the HTML

If the table appears in the page source, you can scrape it with tools like:

  • Python + pandas
  • BeautifulSoup
  • requests + lxml
  • Node.js + cheerio

Python example with pandas

import pandas as pd

url = "https://example.com/page-with-table"
tables = pd.read_html(url)

print(len(tables))      # number of tables found
print(tables[0].head()) # first table

This is often the easiest method if the table is a normal <table> element.


2) Use BeautifulSoup for more control

If pandas.read_html() doesn’t work well, parse the HTML yourself.

import requests
from bs4 import BeautifulSoup

url = "https://example.com/page-with-table"
html = requests.get(url).text
soup = BeautifulSoup(html, "html.parser")

table = soup.find("table")
rows = table.find_all("tr")

data = []
for row in rows:
    cells = row.find_all(["th", "td"])
    data.append([cell.get_text(strip=True) for cell in cells])

for row in data:
    print(row)

3) If the table is loaded dynamically with JavaScript

Sometimes the HTML source doesn’t contain the table data yet; it’s inserted later by JavaScript. In that case:

  • Inspect the page network requests in browser dev tools
  • Look for an API endpoint returning JSON
  • Use a browser automation tool if needed:
    • Selenium
    • Playwright
    • Puppeteer

Selenium example

from selenium import webdriver
from bs4 import BeautifulSoup
import time

driver = webdriver.Chrome()
driver.get("https://example.com/page-with-table")
time.sleep(3)  # wait for JS to load

html = driver.page_source
soup = BeautifulSoup(html, "html.parser")
table = soup.find("table")

driver.quit()

4) If data is embedded in scripts or hidden JSON

Some websites put the data in <script> tags or JavaScript variables. In that case:

  • Inspect the page source
  • Search for JSON-like data
  • Parse it directly if possible

5) Export the extracted data

Once extracted, you can save it as CSV or Excel.

CSV with pandas

df = tables[0]
df.to_csv("table.csv", index=False)

Excel

df.to_excel("table.xlsx", index=False)

6) Important considerations

  • Check the website’s terms of service
  • Respect robots.txt
  • Don’t overload the site with too many requests
  • Use headers and rate limiting if scraping responsibly

Quick recommendation

If the table is in plain HTML, start with:

import pandas as pd
df = pd.read_html("https://example.com")[0]

If that fails, inspect whether the data is loaded by JavaScript and switch to Selenium/Playwright or find the backend API.

If you want, I can show you:

  1. a Python script for a specific website, or
  2. how to tell whether a table is static HTML or JavaScript-loaded.

Observation history

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, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as Circuit. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.