Free plan

Scrape with selectors

Pick out parts of a web page, like titles, prices or links
POST
/v1/documents/scrape

About this tool

This tool reads a public web page and takes out only the parts you ask for. You describe the part with a CSS selector, a short code that points to an element on a page, such as h1 for the main title. You can collect lists, or make one record per item, like a product. The page is only read, never run.
For example, you collect all product names and prices from a shop page into a list.

How to use it

  1. Choose this tool.
  2. Type the web address of the page, or paste the page code.
  3. Type the selector for the part you want, and choose whether to take its text or an attribute such as a link.
  4. Press Generate.
  5. Read the result or download it as CSV.

What you get back

You get a list of the values or records found, on screen, which you can copy or download as a CSV file. It may fail on pages that need a login.
GOOD TO KNOW
Nothing on the page is run. Text leaves out script and style. A page behind a login or built by script after loading is not seen. Counts as one document.
TEST IT LIVE

Try Scrape with selectors in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Documents
Plan
Free
Method
POST
Endpoint
/v1/documents/scrape
Tool ID
documents.scrape
Authentication
API key
Accepts
Text and settings
Background jobs
Yes
Usage group
Documents
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/documents/scrape" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'url=https://example.com/products' \
  -F 'selector=ul.items li a' \
  -F 'extract=text'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.documents.scrape({
    "url": "https://example.com/products",
    "selector": "ul.items li a",
    "extract": "text"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->documents()->scrape([
    'url' => 'https://example.com/products',
    'selector' => 'ul.items li a',
    'extract' => 'text',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Pick values, lists or records out of a web page with CSS selectors: the text, HTML or an attribute of every match, or a record per item of a list. The page is read as text, never run; the address is fetched with the same guard as every other URL input.

Scrape with selectors works from text and settings, so no file is needed. Every input is optional.

Scrape with selectors is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/documents/scrape with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.