python中使用POST上传文件。去哪里看?
我想从这个网站上传并获取结果。 http://cello.life.nctu.edu.tw/
我尝试过
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
register_openers()
params = ({"file": open("xaa", "r"),
"seqtype": "prot",
"species": "eu"})
datagen, headers = multipart_encode(params)
request = urllib2.Request("http://cello.life.nctu.edu.tw/cgi/main.cgi", datagen, headers)
print urllib2.urlopen(request).read()
,但得到了一个错误
Traceback (most recent call last):
File "client.py", line 9, in <module>
a = opener.open("http://cello.life.nctu.edu.tw/cgi/main.cgi", params)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
我不知道这里出了什么问题。有人可以指点我一下吗。 ?谢谢。
顺便提一句。 xaa 文件如下所示 http://pastebin.com/7VK3vvwC
I want to upload and get the result from this website. http://cello.life.nctu.edu.tw/
I tried
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
register_openers()
params = ({"file": open("xaa", "r"),
"seqtype": "prot",
"species": "eu"})
datagen, headers = multipart_encode(params)
request = urllib2.Request("http://cello.life.nctu.edu.tw/cgi/main.cgi", datagen, headers)
print urllib2.urlopen(request).read()
but I got an error
Traceback (most recent call last):
File "client.py", line 9, in <module>
a = opener.open("http://cello.life.nctu.edu.tw/cgi/main.cgi", params)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
I have no idea what is wrong here. Could someone point me out. ? Thanks.
btw. The xaa file looks like this http://pastebin.com/7VK3vvwC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是服务器错误。换句话说,您的代码没有任何问题 - 只是此页面出现错误。
This is a server error. In other words there is nothing wrong with your code - it's just this page errors out.