0

これは私のコードです:

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()

そして、エラーが発生しました:

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

ファイルをアップロードする前に、ログインする必要があります。

だから私はクッキーを使います。

一部のコードは省略されています。

それは問題ではありません。

4

1 に答える 1