This is my code:
user_agent = *Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)*
#######cookie
opener = poster.streaminghttp.register_openers()
opener.add_handler(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
params={*zipFile*:open("123456.zip","rb"),"projectName":"test"}
datagen, headers = poster.encode.multipart_encode(params)
reqIdea = urllib2.Request("http://biqatest.baidu.com/dispatch/project/upload", datagen, headers)
reqIdea.add_header(*User-Agent*,user_agent)
print urllib2.urlopen(reqIdea).read()
and then an error has occurred:
File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 405: Method Not Allowed
Before I upload the file , I have to login.
so I user cookie.
some code is omitted.
that doesn't matter.