0

我正在开发一个包含稻草民意调查的程序。据我所知,这段代码应该可以创建一个民意调查,但是它返回的是错误页面而不是民意调查。这是api

json = json.dumps({"title": "Question", "options": ["option1", "option2", "option3"]})
poll = requests.post("http://strawpoll.me/api/v2/polls", data = json, headers = {"Content-Type": "application/json"})

这是它返回的网址

https://www.strawpoll.me/error?aspxerrorpath=/api/v2/polls
4

2 回答 2

2

不幸的是,strawpoll.me 的 api 已经被破坏了很长一段时间了。您仍然可以检索民意调查,但创建民意调查会将您重定向到错误登录页面。

于 2019-02-08T15:54:46.250 回答
1

尝试将您的请求发布到https://www.strawpoll.me/api/v2/polls

data = {"title": "Question", "options": ["option1", "option2", "option3"]}
poll = requests.post("https://www.strawpoll.me/api/v2/polls", json=data,
                     headers={"Content-Type": "application/json"})

print(poll.url)
# https://www.strawpoll.me/api/v2/polls
print(poll.json())
# {'multi': False, 'title': 'Question', 'votes': [0, 0, 0], 'id': 16578754,
#  'captcha': False, 'dupcheck': 'normal', 'options': ['option1', 'option2', 'option3']}
于 2018-10-04T06:56:49.960 回答