# scrapehtml: Scrape HTML

> scrapehtml (Scrape HTML) is a 1001fx API function in the group Data & JSON: POST https://api.1001fx.com/data/scrapehtml, 1 credit per call. It works as a ready-made module in Make and n8n or as a plain HTTP call.

Scrapes an HTML string or a website and returns the text or attributes of the elements your CSS selectors match.

- Group: Data & JSON
- Endpoint: `POST https://api.1001fx.com/data/scrapehtml`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 1 credit per call
- Ready-made in: Make and n8n
- Docs: https://1001fx.com/functions/scrapehtml

## Parameters

- `html` (string, optional) – HTML String: HTML string to be scraped.
- `url` (string, optional) – Website: Website to be scraped.
- `selectors` (array<object>, required) – Selectors: Array of selectors to search for.
  - `selector` (string, required) – Selector: The CSS selector to search for.
  - `attribute` (string, required) – Attribute: The attribute to return. E.g.: href, src, text.
  - `keyField` (string, required) – Key Field: The field to store the found value in.

## Example: Scrape an HTML snippet

```bash
curl -X POST 'https://api.1001fx.com/data/scrapehtml' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"selectors":[{"selector":"#__next > div > div > main > div > div > div > a","attribute":"href","keyField":"url"}],"url":"https://1001fx.com/blog","html":"<div><a href='\''https://1001fx.com'\''>1001fx</a></div>"}'
```
