在经过身份验证的会话中使用 twill/mechanize 检索 application/json 文档
我需要检索 MIME 类型为“application/json”的文档。我正在使用 twill 登录网站,当我尝试转到
指向 JSON 文档的 URL 并显示
它时,我收到以下消息:
'The HTTP header field "Accept" with value "text/html; */*" could not be parsed.'
我有尝试将“Accept”字段更改为“application/json”,但仍然没有骰子。
谢谢!!
I need to retrieve a document with MIME type "application/json". I'm using twill to log in to a site and when I attempt to go
to the URL pointing to the JSON document and show
it, I get this message:
'The HTTP header field "Accept" with value "text/html; */*" could not be parsed.'
I have tried changing the "Accept" field to "application/json" but still no dice.
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这绝不是我正在寻找的答案,但 zope.testbrowser 可以我想要什么。
界面比斜纹稍微复杂一些,但也不是很多。
仍在寻找斜纹布解决方案!
This is by no means the answer I'm looking for, but zope.testbrowser will do what I want.
The interface is slightly more complicated than twill, but not by much.
Still looking for a twill solution!
看起来你有
Accept: text/html; */*
对我来说似乎语法错误:根据 w3.org< /a>,语法为*/*
,因为它后面是分号而不是逗号,应该是>,但实际上不是
的形式= <浮动>
。您是否想在分号后面添加一个q=something,
,却忘了给出它?否则,只是text/html, */*
——即用逗号,而不是分号——似乎是正确的语法。Looks like you have
Accept: text/html; */*
which seems syntactically wrong to me: per w3.org, the syntax isso that
*/*
, since it follows a semicolon rather than a comma, should be a<param>
, but not in fact of the form<attr> = <float>
. Did you mean to have aq=something,
after the semicolon, and forgot to give it? Else, justtext/html, */*
-- i.e., with a comma, not a semicolon -- seems to be the right syntax.