When I was trying to acess fdty with urllib2, I received a exception which is "HTTP Error 500: Internal Server Error".
the request was:
request = urllib2.Request(
url = "http://www.fdty.fudan.edu.cn/",
headers = {'Connection':'close','Accept-Encoding': 'identity', 'User-Agent': 'Python-urllib/2.5'},
)
and I invoked urllib2.build_opener().open(request).
the error occured.
Whatsmore, I tried in another way which was connecting with httplib.
I sent basic packets by:
conn = httplib.HTTPConnection('www.fdty.fudan.edu.cn')
conn.request('GET', '/tycj/default.asp',None,{'Connection':'close','Accept-Encoding': 'identity', 'User-Agent': 'Python-urllib/2.5'})
res = conn.getresponse()
and then I got the page.
I tried to invade pythonw and caught the packets. To my suprise, I found the two program segments indeed sent the same packets and received the same error message as well. But in the first program, an exception was thrown and the process was terminated; in the latter one, the error message was ignored! After the error message, the server responded with the html I required!
PS: I tried to access the site with C#, While I was using WebRequest or such SocketAPIs, I received the same error message. But when I visit it with WebBrowser, the error message no longer appeared...
尝试使用Python的urllib2访问复旦大学网站时遇到500内部服务器错误,同样的请求通过httplib发送时能成功获取页面,但会显示相同的错误信息。
1603

被折叠的 条评论
为什么被折叠?



