Skip to content
Documentation

Extract data with CSS selectors

POST/v1/crawls/{crawl_id}/extract

Works on the saved HTML, so the crawl needs include_html. Repeat with next_offset until it is null.

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":"price","selector":".price_color"}],"filters":["path:pattern:/catalogue/*"],"limit":1}'
Response 200
{  "total": 49,  "next_offset": 1,  "pages": [    {      "id": 4,      "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",      "title": "A Light in the Attic | Books to Scrape - Sandbox",      "status": 200,      "has_html": true,      "truncated": false,      "values": {        "title": [          "A Light in the Attic"        ],        "price": [          "£51.77"        ]      }    }  ]}

Path parameters

  • crawl_idstringrequired

    Crawl identifier.

Request body

  • fieldsobject[]requiredup to 10 items

    What to extract from each page.

    Fields of fields
    • namestringrequiredup to 60 characters

      Name of the field in the result.

    • selectorstringrequiredup to 500 characters

      CSS selector.

    • formatstringdefault: "text"

      clean_html: no attributes, styles and scripts. attribute: value of the attribute in attribute.

      textmarkdownhtmlclean_htmlattribute

    • attributestring | null

      Attribute name, required when format is attribute.

  • page_idsinteger[] | nullup to 10000 items

    Only these pages. Without it, pages matching the filters.

  • qstringup to 200 characters

    Text in the URL or title. With * it is a path pattern, e.g. /blog/*.

  • filtersstring[]up to 400 charactersup to 10 items

    Conditions written as field:operator:value, e.g. path:pattern:/blog/* or words:gte:300.

  • matchstringdefault: "all"

    Should a page meet all filters or any of them.

    allany

  • limitintegerdefault: 50min: 1max: 100

    Number of pages to return.

  • offsetintegerdefault: 0min: 0max: 100000

    Number of pages to skip.

Response200

  • totalinteger

    Number of selected pages.

  • next_offsetinteger | null

    Offset of the next request. null at the end.

  • pagesobject[]

    May be shorter than limit when the pages are large.

    Fields of pages
    • idinteger

      Page number in the crawl.

    • urlstring

      Address of the page.

    • titlestring

      Content of the title tag.

    • statusinteger | null

      null when the page could not be fetched.

    • has_htmlboolean

      false: the HTML of this page was not saved.

    • truncatedboolean

      true: the page had more data than the limit allows.

    • valuesobject

      Field name and all its matches, in page order.

Errors

Every error has the same format. See what each code means.

401
unauthorized
404
not_found
409
crawl_not_ready
422
invalid_requestinvalid_filterinvalid_selector