web-scraping
Web scraping and data extraction from websites
What this skill does
# Web Scraping
Tools and techniques for fetching and extracting data from web pages.
## Fetch page with curl
```bash
# Fetch a web page and save to file
curl -sL -o page.html "https://example.com"
# Fetch with a custom user agent
curl -sL -A "Mozilla/5.0 (compatible; bot/1.0)" "https://example.com"
# Fetch with headers output
curl -sL -D headers.txt -o page.html "https://example.com"
# Fetch only the HTTP headers
curl -sI "https://example.com"
```
## Extract links with python
```bash
python3 -c "
from html.parser import HTMLParser
class LinkExtractor(HTMLParser):
def __init__(self):
super().__init__()
self.links = []
def handle_starttag(self, tag, attrs):
if tag == 'a':
for name, value in attrs:
if name == 'href':
self.links.append(value)
with open('page.html') as f:
parser = LinkExtractor()
parser.feed(f.read())
for link in parser.links:
print(link)
"
```
## Extract text content
```bash
python3 -c "
from html.parser import HTMLParser
class TextExtractor(HTMLParser):
def __init__(self):
super().__init__()
self.text = []
self._skip = False
def handle_starttag(self, tag, attrs):
if tag in ('script', 'style'):
self._skip = True
def handle_endtag(self, tag):
if tag in ('script', 'style'):
self._skip = False
def handle_data(self, data):
if not self._skip:
stripped = data.strip()
if stripped:
self.text.append(stripped)
with open('page.html') as f:
parser = TextExtractor()
parser.feed(f.read())
print('\n'.join(parser.text))
"
```
## Scrape structured data (tables)
```bash
python3 -c "
from html.parser import HTMLParser
import csv, sys
class TableExtractor(HTMLParser):
def __init__(self):
super().__init__()
self.tables, self.current_table, self.current_row = [], [], []
self.current_cell, self.in_cell = '', False
def handle_starttag(self, tag, attrs):
if tag == 'table': self.current_table = []
elif tag in ('td', 'th'): self.in_cell, self.current_cell = True, ''
elif tag == 'tr': self.current_row = []
def handle_endtag(self, tag):
if tag in ('td', 'th'):
self.in_cell = False
self.current_row.append(self.current_cell.strip())
elif tag == 'tr': self.current_table.append(self.current_row)
elif tag == 'table': self.tables.append(self.current_table)
def handle_data(self, data):
if self.in_cell: self.current_cell += data
with open('page.html') as f:
p = TableExtractor()
p.feed(f.read())
w = csv.writer(sys.stdout)
for table in p.tables:
for row in table:
w.writerow(row)
print('---')
"
```
## Download file
```bash
# Download a file preserving the remote filename
curl -sLOJ "https://example.com/file.zip"
# Download with a specific output name
curl -sL -o output.zip "https://example.com/file.zip"
# Resume an interrupted download
curl -sL -C - -o largefile.zip "https://example.com/largefile.zip"
```
## Follow pagination
```bash
python3 -c "
import subprocess
base_url = 'https://example.com/items?page='
all_content = []
for page in range(1, 11):
url = f'{base_url}{page}'
result = subprocess.run(['curl', '-sL', url], capture_output=True, text=True)
html = result.stdout
if not html.strip() or 'no results' in html.lower():
break
all_content.append(html)
if f'page={page+1}' not in html and 'next' not in html.lower():
break
print(f'Fetched page {page}', flush=True)
with open('all_pages.html', 'w') as f:
f.write('\n'.join(all_content))
print(f'Total pages fetched: {len(all_content)}')
"
```
## Parse JSON-LD/microdata
```bash
python3 -c "
import json, re
with open('page.html') as f:
html = f.read()
# Extract JSON-LD blocks
pattern = r'<script[^>]*type=[\x22\x27]application/ld\+json[\x22\x27][^>]*>(.*?)</script>'
matches = re.findall(pattern, html, re.DOTALL | re.IGNORECASE)
for i, match in enumerate(matches):
try:
data = json.loads(match)
print(f'--- JSON-LD block {i+1} ---')
print(json.dumps(data, indent=2))
except json.JSONDecodeError as e:
print(f'Block {i+1}: parse error: {e}')
# Extract Open Graph and other meta tags
meta_pattern = r'<meta\s+(?:property|name)=[\x22]([^\x22]+)[\x22]\s+content=[\x22]([^\x22]*)[\x22]'
metas = re.findall(meta_pattern, html, re.IGNORECASE)
if metas:
print('--- Meta tags ---')
for name, content in metas:
print(f'{name}: {content}')
"
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.