二进制文件
将 API 指向任意小于 2MB 的二进制文件(图片、PDF、音频等),它会返回一个 JSON 对象,其中包含一个 base64_string 键,该文件以数据 URI 的形式编码。
Endpoint
Section titled “Endpoint” GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<BINARY_FILE_URL>&binary_response=1
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
api_key | string | yes | 您的 Web Scraping API 密钥 |
url | string | yes | 要获取的二进制文件的 URL。 |
binary_response | integer | no | 设置为 1 以强制使用二进制响应格式。 |
Example request
Section titled “Example request”curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F2%2F2f%2FGoogle_2015_logo.svg%2F440px-Google_2015_logo.svg.png"import requests
r = requests.get("https://scrape.shifter.io/v1", params={ "api_key": "YOUR_API_KEY", "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/440px-Google_2015_logo.svg.png", "binary_response": 1,})print(r.json()["base64_string"][:80])import fetch from 'node-fetch';
const url = 'https://scrape.shifter.io/v1?' + new URLSearchParams({ api_key: 'YOUR_API_KEY', url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/440px-Google_2015_logo.svg.png', binary_response: '1',});const res = await fetch(url);const data = await res.json();console.log(data.base64_string.slice(0, 80));Example response
Section titled “Example response”{ "base64_string": "data:image/webp;base64,UklGRlobAABXRUJQVlA4TE4bAAA..."}See also
Section titled “See also”- Web Scraping API - 端点中心
- Basic request