如何使用 pycurl 查看错误消息?
我有以下 pycurl 代码:
卷曲 = pycurl.Curl()
foo = StringIO()
curl.setopt(pycurl.WRITEFUNCTION, foo.write)
curl.setopt(pycurl.POST, 1)
curl.setopt(pycurl.URL, FinalURL)
curl.setopt(pycurl.POSTFIELDS,encodedArgs)
卷曲.perform()
响应代码=curl.getinfo(pycurl.RESPONSE_CODE)
effectiveURL =curl.getinfo(pycurl.EFFECTIVE_URL)
卷曲.close()
命令行curl命令返回时,我看到:
当 HTTP/1.1 200 好 服务器:Apache-Coyote/1.1
内容类型:text/xml;字符集=UTF-8
内容长度:216
日期:2011 年 1 月 6 日星期四 15:49:36 GMT
这里出现一些 XML 错误:不允许您尝试执行的操作。
但我没有从 pycurl 中看到这一点。
使用 pycurl 时如何提取此警报/错误消息?
I have the following pycurl code:
curl = pycurl.Curl()
foo = StringIO()
curl.setopt(pycurl.WRITEFUNCTION, foo.write)
curl.setopt(pycurl.POST, 1)
curl.setopt(pycurl.URL, finalURL)
curl.setopt(pycurl.POSTFIELDS, encodedArgs)
curl.perform()
responseCode = curl.getinfo(pycurl.RESPONSE_CODE)
effectiveURL = curl.getinfo(pycurl.EFFECTIVE_URL)
curl.close()
When the command line curl command comes back I see:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=UTF-8
Content-Length: 216
Date: Thu, 06 Jan 2011 15:49:36 GMT
Some XML Error Here: Something you are trying to do is not permitted.
But I don't see this from pycurl.
How can I extract this alert/error message when using pycurl?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自服务器的响应是使用curl选项
pycurl.WRITEFUNCTION
写入的。在您的情况下,由于您向其传递一个
StringIO
对象,因此响应数据应该位于foo
变量中:foo.getvalue()
参考: http://pycurl.sourceforge.net/doc/curlobject.html
The response from the server is written using the curl option
pycurl.WRITEFUNCTION
.In your case, since you are passing it a
StringIO
object, the response data should be in thefoo
variable:foo.getvalue()
Reference: http://pycurl.sourceforge.net/doc/curlobject.html