Wyciągnij dane selektorami CSS
POST/v1/crawls/{crawl_id}/extract
Działa na zapisanym HTML-u, więc crawl musi mieć include_html. Powtarzaj zapytanie z next_offset, aż będzie 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}'{ "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" ] } } ]}Parametry ścieżki
crawl_idstringwymaganeIdentyfikator crawla.
Treść zapytania
fieldsobject[]wymaganedo 10 elementówCo wyciągnąć z każdej strony.
Pola fields
namestringwymaganedo 60 znakówNazwa pola w wyniku.
selectorstringwymaganedo 500 znakówSelektor CSS.
formatstringdomyślnie: "text"clean_html: bez atrybutów, stylów i skryptów. attribute: wartość atrybutu podanego w
attribute.textmarkdownhtmlclean_htmlattributeattributestring | nullNazwa atrybutu, wymagana, gdy format to attribute.
page_idsinteger[] | nulldo 10000 elementówTylko te strony. Bez tego pola strony pasujące do filtrów.
qstringdo 200 znakówTekst w adresie albo tytule. Z
*to wzorzec ścieżki, np./blog/*.filtersstring[]do 400 znakówdo 10 elementówWarunki w postaci
pole:operator:wartość, np.path:pattern:/blog/*albowords:gte:300.matchstringdomyślnie: "all"Czy strona ma spełniać wszystkie warunki, czy dowolny z nich.
allanylimitintegerdomyślnie: 50min.: 1maks.: 100Ile stron zwrócić.
offsetintegerdomyślnie: 0min.: 0maks.: 100000Ile stron pominąć.
Odpowiedź200
totalintegerLiczba wybranych stron.
next_offsetinteger | nullWartość offset następnego zapytania. Na końcu null.
pagesobject[]Może być krótsza niż
limit, gdy strony są duże.Pola pages
idintegerNumer strony w crawlu.
urlstringAdres strony.
titlestringTreść znacznika title.
statusinteger | nullnull, gdy strony nie udało się pobrać.
has_htmlbooleanfalse: HTML tej strony nie został zapisany.
truncatedbooleantrue: strona miała więcej danych, niż pozwala limit.
valuesobjectNazwa pola i wszystkie dopasowania w kolejności na stronie.
Błędy
Każdy błąd ma ten sam format. Zobacz, co oznaczają kody.
- 401
- unauthorized
- 404
- not_found
- 409
- crawl_not_ready
- 422
- invalid_requestinvalid_filterinvalid_selector