Extract data
Collect prices, authors, articles and anything else from many pages with CSS selectors.
Extraction reads the HTML saved by a crawl. It does not fetch pages again and does not use tokens, so you can correct the selectors as many times as you need.
The crawl must save HTML. The option include_html is on by default.
In the panel
- Open a crawl and select pages, for example all that match
/blog/*. - Click Extract data and enter the selectors.
- Copy the result or download it as CSV or JSON.
In the API
Each field has a name and a CSS selector:
curl -X POST https://api.seoscraper.io/v1/crawls/CRAWL_ID/extract \
-H "Authorization: Bearer ssk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"fields": [
{"name": "title", "selector": "h1"},
{"name": "content", "selector": "article", "format": "markdown"},
{"name": "image", "selector": "article img", "format": "attribute", "attribute": "src"}
],
"filters": ["path:pattern:/blog/*"]
}'In the response, values has all matches of each field in page order:
{
"total": 128,
"next_offset": 50,
"pages": [
{
"id": 12,
"url": "https://example.com/blog/first-post",
"title": "First post",
"status": 200,
"has_html": true,
"truncated": false,
"values": {
"title": ["First post"],
"content": ["Text of the article in Markdown."],
"image": ["https://example.com/images/first.jpg"]
}
}
]
}Formats
format | Result |
|---|---|
text | Text with line breaks, similar to what you see on the page. This is the default. |
markdown | Markdown with headings, lists, links and images |
html | The original HTML of the element |
clean_html | HTML without attributes, styles and scripts |
attribute | The value of the attribute given in attribute |
Addresses in Markdown and in attributes such as href and src are always absolute.
Which pages
Choose pages with filters or send their numbers in page_ids. Without either, all pages of the crawl are read.
Read everything
One response holds up to 100 pages and about 2 MB, so it may be shorter than limit. Repeat the request with offset equal to next_offset until it is null:
import requests
URL = "https://api.seoscraper.io/v1/crawls/CRAWL_ID/extract"
HEADERS = {"Authorization": "Bearer ssk_YOUR_KEY"}
pages, offset = [], 0
while offset is not None:
body = {"fields": [{"name": "title", "selector": "h1"}], "offset": offset}
data = requests.post(URL, headers=HEADERS, json=body, timeout=40).json()
pages += data["pages"]
offset = data["next_offset"]
print(len(pages))Limits
- Up to 10 fields in one request.
- Up to 1,000 matches of one field on one page and about 1 MB of data from one page. When there was more,
truncatedistrue. - A selector that is not valid returns
422 invalid_selector. has_html: falsemeans that the HTML of this page was not saved.