Skip to content
登录 注册

JavaScript 指令

将经过 URL 编码的浏览器操作 JSON 数组传递给 js_instructions。API 会按顺序执行这些操作,然后返回最终的 HTML。这对分页列表、无限滚动和表单驱动的流程非常有用。

GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&render_js=1&js_instructions=<URL_ENCODED_JSON>
ParameterTypeRequiredDescription
api_keystringyes您的 Web Scraping API 密钥
urlstringyes要抓取的目标 URL
js_instructionsstringyes经过 URL 编码的操作对象 JSON 数组。
render_jsintegeryes必须为 1
FieldTypeDescription
actionstring取值为 clickscrollTofocusvaluesubmit(仅表单)之一。
selectorstring目标元素的 CSS 选择器。
timeoutinteger此操作完成后等待的毫秒数。
[{"action":"scrollTo","selector":"div.navFooterBackToTop","timeout":5000,"block":"start"}]
Terminal window
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&render_js=1&js_instructions=%5B%7B%22action%22%3A%22scrollTo%22%2C%22selector%22%3A%22div.navFooterBackToTop%22%2C%22timeout%22%3A%205000%2C%20%22block%22%3A%20%22start%22%7D%5D"
<!doctype html>
<html>
<head>
<title>Example Domain</title>
</head>
<body>
<div>
<h1>Example Domain</h1>
<p>This domain is for use in illustrative examples in documents.</p>
</div>
</body>
</html>