To scrape data from a website, start with one page and decide what each row in your spreadsheet should contain. This guide uses a public workshop listing to show how to collect names, dates, locations, and registration status with Google Sheets or Python. You’ll export the results to CSV and check that every listing made it into the file, including the one with a blank location.
What’s the quickest way to scrape data from a website?
If the data is already in a public HTML table, import it into Google Sheets and download a CSV. For repeating cards or listings, try a visual scraper. Use Python when you need to choose specific fields or check the output automatically. If the data appears only after the page loads, check for a source API or an export before choosing a tool that can run JavaScript.
Check the source first. A source’s own API or CSV export may already provide the fields you need. If you collect from web pages, field availability depends on what the page displays, how it loads, and the access available for your project.
What you’ll get
One row per workshop and four columns. Here are the first three of the six records you should see.
| workshop | date | location | status |
|---|---|---|---|
| Intro to Data Analysis | 2027-01-12 | Austin | Open |
| Spreadsheet Basics | 2027-01-14 | Boston | Open |
| Python for Beginners | 2027-01-19 | Chicago | Waitlist |
1. Check how the page loads the data
Web scraping extracts selected information from a page and turns it into structured records. For example, you might collect one row per workshop, one row per job posting, or one row per location. Decide what a single row represents before choosing a tool. If you need to discover links across a site first, that discovery step is web crawling.
Open the workshop listings practice page. It contains six fictional records. We’ll collect the workshop name, date, location, and registration status. The last workshop has a blank location, which gives us a way to check that the export preserves missing values.
- Right-click a workshop name and choose Inspect. Find the cell (
<td>) and the row (<tr>) that contains it. - Move up to the table. Its ID is
workshops. The selector#workshops tbody trfinds the data rows and skips the header. - Open View Page Source and search for
Intro to Data Analysis. If you can find the row there, the page includes the data in its HTML. If you see rows only in the browser’s Elements panel, JavaScript may be loading them after the initial request.
2. Scrape an HTML table into Google Sheets
Use Google Sheets for a quick import when the page publishes the data in an accessible HTML table. Open a blank spreadsheet and paste this formula into cell A1. Choose either this method or the Python method below, then compare your result with the sample CSV.
=IMPORTHTML("https://kvetoiq.com/workshop-listings-demo.html","table",1)
The final argument selects the first table on the page. Expect the headers in A1:D1 and six records in rows 2–7. Cell C7 should be empty and D7 should still read Open. Use File → Download → Comma-separated values (.csv) to save the sheet. In Excel, use Data → From Text/CSV if you want to control how Excel interprets dates and text. For other tables and lists, see Google’s IMPORTHTML documentation.
3. Scrape the same web page with Python
Python gives you control over which rows to extract and how to handle changes in the table. Install the lxml HTML parser, then save the script below as scrape_workshops.py.
python -m pip install lxml
import csv
import sys
from urllib.request import urlopen
from lxml import html
URL = "https://kvetoiq.com/workshop-listings-demo.html"
FIELDS = ("workshop", "date", "location", "status")
def main(url):
with urlopen(url, timeout=15) as response:
page = html.fromstring(response.read())
table = page.get_element_by_id("workshops")
headers = [cell.text_content().strip() for cell in table.findall("thead/tr/th")]
if headers != list(FIELDS):
raise ValueError(f"Unexpected workshop table headers: {headers}")
rows = []
for row in table.findall("tbody/tr"):
cells = [cell.text_content().strip() for cell in row.findall("td")]
if len(cells) != len(FIELDS):
raise ValueError(f"Expected {len(FIELDS)} cells, got {len(cells)}")
rows.append(cells)
if not rows:
raise ValueError("The workshop table contains no data rows.")
with open("workshops.csv", "w", newline="", encoding="utf-8") as output:
writer = csv.writer(output)
writer.writerow(FIELDS)
writer.writerows(rows)
print(f"Saved {len(rows)} rows to workshops.csv")
if __name__ == "__main__":
main(sys.argv[1] if len(sys.argv) > 1 else URL)
Run the script from the folder where you saved it. On Windows, you can use py in place of python if that is how your Python installation launches.
python scrape_workshops.py
Look for Saved 6 rows to workshops.csv. The file appears in the folder where you ran the command. If the request fails or the table layout changes, the script reports the error before writing the export.
To adapt the script to another HTML table, change URL, replace workshops with the target table’s ID, and update FIELDS to match its column headings in order. Use the CSV checks below on a small sample before collecting more pages.
4. Verify the CSV against the source page
- Count the records. The file should contain six workshop rows plus one header row.
- Check individual values. Confirm that Spreadsheet Basics is in Boston and that Build Your First Dashboard is marked Full.
- Check the column boundaries. Working with Public Data has a blank location. Its status should still appear under
status. If your spreadsheet reformats a date, compare the date value as well as its display format.
Download the expected workshop CSV to compare it with your export.
Try a scrape that succeeds but misses rows
In a copy of the Python script, insert the following line immediately before if not rows:, with the same indentation as that line. Run the copy in a separate folder so you keep the complete export.
rows = rows[:3]
The script still writes a CSV with all four headers and prints Saved 3 rows to workshops.csv. The count check catches the missing records. On a live site, this can happen when your scraper stops after the first page or selects only some of the rows. Remove the test line to restore the full export.
What to do when your scrape returns missing or empty data
| What you see | What to check |
|---|---|
| No table or an empty result | Search the original page source for a visible row. If the site loads the rows with JavaScript, look for an official API or an authorized export. Browser automation can be an option where you have permission. |
| The wrong table | Check the table index in Sheets. In Python, confirm the table ID and compare the column headers with what you expected. |
| Only the first set of rows | Check for page numbers or a load-more button. Follow the available pages or use the source’s export, then check for duplicates. |
| A 403, 429, or login page | Check access before retrying. Use an authorized method for restricted data. For a rate limit, respect the site’s limits and any retry instructions. |
How to handle multiple pages
Start with two pages. Save the source page URL alongside each record and check that the second page adds new records. Prefer a listing ID or detail URL for deduplication if the site provides one. Stop when there is no next page or when a request returns the same page again. A repeated page or a request failure deserves a note in the run log so you can tell whether the export is complete.
How to check for JavaScript-rendered data
If you can see a record in the browser but cannot find it in the original page source, compare the browser’s Elements panel with the HTML response your scraper receives. The data may load after the page opens or after you click a control. Use an authorized data source or a rendering tool when the workflow needs that extra step. Test that the rendered page contains the intended record before expanding collection.
When to use a scraper tool, API, or managed service
| Method | Best fit | What to check before you start |
|---|---|---|
| Spreadsheet import | One accessible HTML table, with results for Sheets or Excel. | Confirm the rows appear in the page source and the correct table imports. |
| No-code scraper tool | Repeated elements such as cards or directory listings. | Test that the tool keeps fields in the right row and can follow a second page. |
| Python script | Custom field selection, cleaning, or validation. | Check that the script receives the expected HTML. Plan who will update it when the layout changes. |
| Web scraping API | Programmatic collection that needs fetching or browser rendering. | Check whether the response contains HTML or ready-to-use records and what your application still needs to process. |
| Managed web scraping service | Recurring data across sources, with collection and validation handled by a provider. | Review a sample for field coverage, then agree on delivery frequency and how failures will be reported. |
For a one-time export, test the simplest method on a representative page. For recurring collection, also test a page with missing fields and a page that loads differently.
How to scrape a website with a no-code scraper tool
A visual scraper is useful for repeating page elements such as cards, directory listings, and search results. Try the steps below on the workshop practice page so you have a known result to compare. Controls vary by tool.
- Open the practice page in the tool. Select one full workshop row as the repeating record, then confirm the preview recognizes all six rows.
- Within each row, select the workshop name, date, location, and status as four separate fields. Use the preview to confirm that a blank location stays blank and the status remains in its own column.
- Run a one-page test, export the CSV, and compare the headers and record count with the sample file. When moving to a site with multiple pages, test the first two pages before collecting the full list.
Check that the tool supports the page behavior you need, such as a Next button or fields inside each listing’s detail page. You can compare browser extensions and visual tools in the web scraping tools guide.
When to use a web scraping API
Use a scraping API when your application needs to collect pages programmatically and you want help with page fetching or browser rendering. Start with a single URL and check what the endpoint returns. If it returns HTML, your code still needs to extract the fields. If it returns structured data, compare those fields with what the source actually shows.
Test one page that loads its data with JavaScript and one page with a missing field. Decide how your application will report empty results and rate limits before you schedule larger runs. If the source offers its own authorized API with the fields you need, evaluate that option first. See web scraping vs. source APIs and the Kvetoiq web scraping API.
How a managed website scraping project works
Suppose you need a weekly directory of workshops from several sites. Two sites might list the same event, one might omit the location, and another might remove past events without warning. A managed project starts by agreeing on how those cases should appear in the delivery.
- Define the dataset. Share representative URLs, the fields you need, the refresh schedule, and how your team will use the data. Decide whether a row represents a workshop or a specific session.
- Review the sources and a sample. Check field availability and compare sample records with their source pages. Agree on how to identify duplicate sessions and flag missing values.
- Agree on delivery and exceptions. Choose CSV, JSON, or another agreed format. For recurring delivery, ask for source URLs and collection timestamps so you can trace each row. Agree on how the delivery will report a source that failed.
Kvetoiq’s managed web scraping team can review your sources and scope a sample around those requirements. For the operational details, see the guide to building a reliable scraping pipeline.
Common questions about scraping a website
Can I scrape a website that requires a login?
Check what access your account grants and whether the site permits automated collection for your use. An account export or an authorized integration may already provide the required records. The examples in this guide use a public practice page.
Can I scrape data from a website for free and open it in Excel?
For the practice page, you can use the Python script with a free HTML parser or import the table in Google Sheets and download a CSV. In Excel, import the CSV as text if you need to preserve date formatting or identifiers with leading zeros.
Can ChatGPT help with web scraping?
ChatGPT can help explain HTML, draft a selector, or debug code using a sample of the page. Run the extraction in your chosen tool and verify the output against the source before using it.
Is web scraping legal?
Access rules, the data being collected, and its intended use matter. Start with a source you have permission to use. See Kvetoiq’s guide to web scraping legality for more context.
Need a dataset from specific websites?
Send Kvetoiq a few representative URLs, the fields you need, your preferred output format, and how often the data should refresh. We’ll review what the sources can provide and scope a sample you can check before planning a recurring delivery.
Request a data sample from Kvetoiq
Leave A Comment