web-scraper
БесплатноБез исполняемых скриптовНе проверенExtract structured data from web pages and load it into databases. Use when a user asks to scrape a website, build a data pipeline, extract data from a…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Web Scraper
Overview
Extract structured data from web pages by parsing HTML, selecting elements with CSS selectors, and outputting clean data in JSON, CSV, or other formats. Handles both static HTML and JavaScript-rendered pages.
Instructions
When a user asks you to scrape or extract data from a web page, follow these steps:
Step 1: Assess the target
Determine:
- URL: What page to scrape
- Data needed: What specific elements to extract (prices, titles, links, tables)
- Rendering: Is the page static HTML or does it require JavaScript?
- Scale: Single page or multiple pages with pagination?
Step 2: Fetch the page
For static HTML:
import requests
from bs4 import BeautifulSoup
def fetch_page(url):
headers = {
"User-Agent": "Mozilla/5.0 (compatible; research-bot/1.0)"
}
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
# Pass bytes, not response.text: when the Content-Type header has no
# charset, requests guesses one and symbols such as £ turn into mojibake.
return BeautifulSoup(response.content, "html.parser")
For JavaScript-rendered pages (pip install playwright, then playwright install once to download the browsers):
from playwright.sync_api import sync_playwright
def fetch_js_page(url):
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.goto(url, wait_until="networkidle")
content = page.content()
browser.close()
return BeautifulSoup(content, "html.parser")
Step 3: Extract data with CSS selectors
Identify the right selectors by inspecting the page structure:
def extract_items(soup, selectors):
items = []
containers = soup.select(selectors["container"])
for container in containers:
item = {}
for field, selector in selectors["fields"].items():
el = container.select_one(selector)
if el:
if el.name == "img":
item[field] = el.get("src", "")
elif el.name == "a":
item[field] = {"text": el.get_text(strip=True), "href": el.get("href", "")}
else:
item[field] = el.get_text(strip=True)
else:
item[field] = None
items.append(item)
return items
Usage example:
selectors = {
"container": "div.product-card",
"fields": {"name": "h2.product-title", "price": "span.price", "rating": "span.rating-value", "link": "a.product-link"},
}
items = extract_items(soup, selectors)
Step 4: Handle pagination
def scrape_all_pages(base_url, selectors, max_pages=10):
all_items = []
for page_num in range(1, max_pages + 1):
url = f"{base_url}?page={page_num}"
soup = fetch_page(url)
items = extract_items(soup, selectors)
if not items:
break
all_items.extend(items)
return all_items
Step 5: Output structured data
import json
import csv
def save_json(data, filename):
with open(filename, "w") as f:
json.dump(data, f, indent=2)
def save_csv(data, filename):
if not data:
return
with open(filename, "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=data[0].keys())
writer.writeheader()
writer.writerows(data)
Examples
Example 1: Extract product listings
User request: "Scrape all product names and prices from this catalog page"
Script outline:
soup = fetch_page("https://books.toscrape.com/") # public practice site for scrapers
products = []
for card in soup.select("article.product_pod"):
link = card.select_one("h3 a")
price = card.select_one("p.price_color")
products.append({
"name": link.get("title", "N/A") if link else "N/A",
"price": price.get_text(strip=True) if price else "N/A",
})
save_csv(products, "products.csv")
print(f"Extracted {len(products)} products")
Output:
Extracted 20 products
| name | price |
|----------------------|---------|
| A Light in the Attic | £51.77 |
| Tipping the Velvet | £53.74 |
Example 2: Extract a data table from a page
User request: "Pull the statistics table from this Wikipedia article"
Script outline:
soup = fetch_page("https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)")
table = soup.select_one("table.wikitable")
headers = [th.get_text(strip=True) for th in table.select("tr:first-child th")]
rows = []
for tr in table.select("tr")[1:]:
cells = [td.get_text(strip=True) for td in tr.select("td")]
if len(cells) == len(headers):
rows.append(dict(zip(headers, cells)))
save_json(rows, "table_data.json")
print(f"Extracted {len(rows)} rows with columns: {headers}")
Output:
Extracted
Установить web-scraper в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл web-scraper?
Extract structured data from web pages and load it into databases. Use when a user asks to scrape a website, build a data pipeline, extract data from a webpage, pull prices from a site, collect links, gather product listings, download page content, parse HTML, set up ETL, or automate data collection. Handles static HTML, JavaScript-rendered pages, anti-bot proxies (Bright Data), data transformation, deduplication, and database loading.
Как установить скилл web-scraper?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл web-scraper запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic