我正在CloudScrape向我的在线网站抓取工具发出API请求,documentation显示以下示例。
POST / api / runs / {runId} / execute / inputs / wait HTTP / 1.1
X-CloudScrape-Access:ga09usdm8osdf8n9sodf
X-CloudScrape-Account:87750c5f-7423-4438-b3f1-7b8b86990621
接受:application / json
Accept-Encoding:gzip
Content-Type:application / json
主持人:app.cloudscrape.com
User-Agent:YourApp / 1.0
{ "my_input_field": "My input value", "my_other_input_field": 234 }
我想发布以下参数;
body,runId
到目前为止,我已经尝试了
import requests
import json
client = requests.session()
runID = '86df246f-8f77-47b9-9655-be61e3851839'
inputQuery = {"query": "1080p category:movies user:z0n321 imdb:3659388"}
data = {'body':inputQuery, 'runId':'86df246f-8f77-47b9-9655-be61e3851839'}
headers = {'X-CloudScrape-Access':'a41c493c2a31d068f1a06333311e52f7', 'X-CloudScrape-Account':'87750c5f-7423-4438-b3f1-7b8b86990621', 'Accept':'application/json', 'Content-Type':'application/json'}
response = client.post('https://app.cloudscrape.com/api/runs/{%s}/execute/inputs/wait' % runID, data=json.dumps(data), headers=headers)
results = json.loads(response.content)
print results
我收到此回复{u'code': 404, u'error': True}
当我通过他们的网站手动运行我的刮刀运行正常。我做错了吗?
答案 0 :(得分:3)
你没有正确格式化它。这样做:
'https://app.cloudscrape.com/api/runs/{}/execute/inputs/wait'.format(runID)
答案 1 :(得分:2)
您不需要插值参数周围的大括号。
...api/runs/%s/execute...