我正在尝试使用Quizlet API在Python中创建一个脚本,该API搜索具有特定术语的集合。唯一的问题是我收到此错误:
{"http_code":400,"error":"client_developer_error","error_title":"Error","error_description":"setAction called with null action"}
这是脚本:
import requests
import os
id = ''
key = ''
def err_fill_out():
print '[-] Please fill out your terms.txt file'
exit(1)
if os.path.exists('terms.txt'):
print '[*] Found terms.txt ...'
terms = [i.strip() for i in open('terms.txt', 'r+').readlines()]
if len(terms) == 0:
err_fill_out()
for i in terms:
print '[*] Looking for best term of', i, '...'
r = requests.post(url='https://api.quizlet.com/2.0/search/sets', data={"client_id": id, "access_token": key, "term": i, "sort": "most_studied"})
print r.text
else:
open('terms.txt', 'w+')
err_fill_out()
答案 0 :(得分:0)
看起来您的请求不太正确。我不确定您是如何使用您发布的代码获得该错误的。
再次查看文档页面:https://quizlet.com/api/2.0/docs/searching-sets
一些事情:
get
q
而不是term
sort
已弃用我能用这一行获得结果:
r = requests.get(url='https://api.quizlet.com/2.0/search/sets', params={"client_id": id, "access_token": key, "q": i})