首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Python中的机器连接到安全网站

无法使用Python中的机器连接到安全网站
EN

Stack Overflow用户
提问于 2012-10-17 05:13:37
回答 1查看 820关注 0票数 0

我试图使用Python中的机器库打开一个安全的(https)网站。当我试图访问该网站时,服务器将关闭连接并引发异常BadStatusLine。

我尝试使用addheaders属性修改标头,但没有响应。

代码语言:javascript
复制
import mechanize

br = mechanize.Browser()
print 'opening page ...'
resp = br.open('https://onlineservices.tin.nsdl.com/etaxnew/tdsnontds.jsp')     #this one works fine
print 'ok'

print 'opening page 2 ...'
resp = br.open('https://incometaxindiaefiling.gov.in/portal/index.do')          #exception raised 
print 'ok'

例外:

回溯(最近一次调用):pydev_imports.execfile文件(文件、全局文件、局部变量)#在resp=br.open('https://incometaxindiaefiling.gov.in/portal/index.do')中执行脚本文件"Z:\pyTax\app_test.py",第22行 文件"build\bdist.win32\egg\mechanize_mechanize.py",第203行,打开文件"build\bdist.win32\egg\mechanize_mechanize.py",第230行,_mech_open文件"build\bdist.win32\egg\mechanize_opener.py",第188行,打开文件"build\bdist.win32\egg\mechanize_http.py",第316行,http_request文件"build\bdist.win32\egg\mechanize_http.py",第242行,在“读取文件”"build\bdist.win32\egg\mechanize_mechanize.py",第203行中,打开 文件"build\bdist.win32\egg\mechanize_mechanize.py",第230行,在_mech_open文件"build\bdist.win32\egg\mechanize_opener.py“中,第193行,在打开的文件"build\bdist.win32\egg\mechanize_urllib2_fork.py",第344行,在_open文件"build\bdist.win32\egg\mechanize_urllib2_fork.py",第332行,在_call_chain文件"build\bdist.win32\egg\mechanize_urllib2_fork.py",第1170行,在"build\bdist.win32\egg\mechanize_urllib2_fork.py",文件第1116行,do_open文件"D:\Python27\lib\httplib.py",第1031行,getresponse response.begin()文件"D:\Python27\lib\httplib.py",第407行,开始版本,状态,原因= self._read_status()文件"D:\Python27\lib\httplib.py",第371行,在_read_status BadStatusLine(行)httplib.BadStatusLine中:'‘

EN

回答 1

Stack Overflow用户

发布于 2012-10-17 05:29:34

httplib.BadStatusLineisHTTPException的一个子类。如果服务器使用我们不理解的HTTP状态代码进行响应,则引发。这就是导致你问题的原因。不过,我并不完全确定修复程序,因为您的代码在我的计算机上运行得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12927516

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档