curl --request POST --url https://unlocker-api.lunaproxy.com/request --header "Authorization: Bearer token" --header "content-type: application/json" --data "{\"url\":\"https://www.google.com/\",\"type\":\"html\",\"js_render\":\"False\"}" > google.html
在這個示例中,我們將渲染YouTube的主頁,並抓取頁面內容。通常情況下,如果使用了通用抓取API而不使用Javascript渲染,則YouTube的主頁樣式如下:
curl --request POST --url https://unlocker-api.lunaproxy.com/request --header "Authorization: Bearer token" --header "content-type: application/json" --data "{\"url\":\"https://www.google.com/\",\"type\":\"html\",\"js_render\":\"True\"}" > google.html
curl --request POST --url https://unlocker-api.lunaproxy.com/request --header "Authorization: Bearer token" --header "content-type: application/json" --data "{\"url\":\"https://www.google.com/\",\"type\":\"png\",\"js_render\":\"True\"}" > google.png
啟用 JavaScript 渲染產生的消耗高於未開啟,且速度會變慢。
curl --request POST --url
https://unlocker-api.lunaproxy.com/request
--header "Authorization: Bearer token" --header "content-type: application/json" --data "{\"url\":\"
https://www.google.com/\",\"type\":\"png\",\"js_render\":\"True\"}"
> google.png