Scraping API快速入门入门

开始使用

参数字段

参数类型说明
actorstring非常重要的参数,代表服务类型。点击查看scraper actor列表信息
inputobject提交actor所需要的参数,完成一次数据抓取。
proxyobjectcountry字段,使用该地区的代理发送请求。

任务成功说明

  • http code 为 200,代表任务已经成功,response body就是数据。

任务处理中说明

  • http code 为 201,代表任务正在处理中,请通过 taskId 获取任务结果。
{
  "message": "task in progress",
  "taskId":"30681c8b-bfd3-48eb-a7c9-006e40b00591"
}

任务失败说明

  • http code 为 429. Too many request。
  • Http code 为 400,请检查任务参数是否合法。
  • Http code 为 500,服务器内部错误。

请求范例

使用Python获取shopee数据

import requests
import json
 
API_KEY = ""
host = "api.scrapeless.com"
url = f"https://{host}/api/v1/scraper/request"
 
payload = json.dumps({
   "actor": "scraper.shopee",
   "input": {
      "action": "shopee.product",
      "url": "https://shopee.tw/2312312.10228173.24803858474"
   }
})
headers = {
   'Content-Type': 'application/json',
   'x-api-token': f'{API_KEY}'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)