Stawpoll无法创建民意调查

时间:2018-10-04 06:28:55

标签: python api

我正在研究一个包含稻草投票的程序。据我所知,此代码应该可以创建轮询,但是它返回的是错误页面而不是轮询。这是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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

尝试将您的请求发布到http s :// 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']}
相关问题