高级功能
通过 custom_headers 以 URL 编码的 JSON 对象形式传递标头:
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://api.example.com&custom_headers=%7B%22Authorization%22%3A%22Bearer%20abc123%22%7D"当目标网站需要 bearer 令牌、X-Requested-With: XMLHttpRequest 或语言区域偏好设置时,这非常有用。
自定义 cookie
Section titled “自定义 cookie”通过 custom_cookies 内联设置 cookie:
cookie_name=value; other_name=value2URL 编码后:
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&custom_cookies=session_id%3Dabc%3B%20locale%3Den-US"如需在多个请求之间使用 cookie,建议使用 session_id,服务器设置的 cookie 会自动保留。
POST 和 PUT
Section titled “POST 和 PUT”使用 method 切换方法。请求体作为请求正文传递。
curl -X POST \ "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://api.example.com/users&method=POST" \ -H "Content-Type: application/json" \ -d '{"email":"user@example.com","plan":"pro"}'PUT 用法相同,使用 method=PUT 即可。
返回完整页面的 PNG 图像,而非 HTML:
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&render_js=1&screenshot=1" \ -o screenshot.png选项:
screenshot_full_page=1,捕获超出视口范围的内容。screenshot_selector=<css>,仅捕获单个元素。
对于 PDF、图片或任何非文本响应,添加 binary_response=1。抓取器会通过以下方式流式传输二进制载荷:
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com/file.pdf&binary_response=1" \ -o file.pdf某些目标网站会标记默认浏览器指纹。您可以禁用隐身模式以进行调试(不建议在生产环境中使用):
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&disable_stealth=1&render_js=1"组合使用标志
Section titled “组合使用标志”所有标志均可组合使用。一个真实场景的请求示例如下:
curl "https://scrape.shifter.io/v1?\api_key=YOUR_API_KEY&\url=https://shop.example.com/products/42&\render_js=1&\wait_for_css=.price&\session_id=cart-001&\premium_proxy=1&\country=us&\extract_rules=%7B%22price%22%3A%7B%22selector%22%3A%22.price%22%2C%22output%22%3A%22text%22%7D%7D"一次成功的请求,消耗一个信用点。