JSON自动解析器
设置 auto_parser=1,即可让 API 将页面解析为由标签、属性和文本组成的嵌套 JSON 结构。无论是否启用 JavaScript 渲染均可使用。
Endpoint
Section titled “Endpoint” GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&auto_parser=1
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
api_key | string | 是 | 您的 Web Scraping API 密钥 |
url | string | 是 | 要抓取的目标 URL |
auto_parser | integer | 否 | 0(默认)或 1。设为 1 时,响应将返回解析后的 JSON。 |
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&auto_parser=1"import requests
r = requests.get("https://scrape.shifter.io/v1", params={ "api_key": "YOUR_API_KEY", "url": "https://example.com", "auto_parser": 1,})print(r.json())import fetch from 'node-fetch';
const url = 'https://scrape.shifter.io/v1?' + new URLSearchParams({ api_key: 'YOUR_API_KEY', url: 'https://example.com', auto_parser: '1',});const res = await fetch(url);console.log(await res.json());{ "0": { "tagName": "div", "children": { "0": { "tagName": "h1", "text": "Example Domain" }, "1": { "tagName": "p", "text": "This domain is for use in illustrative examples in documents." }, "2": { "tagName": "p", "text": "More information...", "children": { "0": { "tagName": "a", "attributes": { "href": "https://www.iana.org/domains/example" }, "text": "More information..." } } } } }}