Skip to content
Login Sign up

Extraction rules

Pass URL-encoded JSON to extract_rules to get structured output from the target page. Each rule has a CSS selector, an optional output type, and a flag to return all matches. Extraction rules work with or without JavaScript rendering.

GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&extract_rules=<URL_ENCODED_JSON>
ParameterTypeRequiredDescription
api_keystringyesYour Web Scraping API key
urlstringyesTarget URL to fetch
extract_rulesstringyesURL-encoded JSON describing the extraction rules.
FieldTypeRequiredDescription
selectorstringyesCSS selector.
outputstringnohtml (default), text, or @attr to pull an attribute.
allstringno"1" to return all matches as an array, "0" (default) for the first match.

Extract the page title as text:

{"title": {"selector": "h1", "output": "text"}}
Terminal window
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https%3A%2F%2Fexample.com&extract_rules=%7B%22title%22%3A%20%7B%22selector%22%3A%20%22h1%22%2C%20%22output%22%3A%20%22text%22%7D%7D"
{ "title": "Example Domain" }