-1
我試圖讓POST請求的響應狀態檢查-python
然後檢查響應報頭狀態碼
200或302
import urllib
import urllib2
url = 'url' #url
values = {'name' : 'Michael Foord',
'location' : 'Northampton',
'language' : 'Python' } #post data
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
當我嘗試
response.getcode()
th e結果是200即使結果是302-FOUND 有什麼想法?
當我檢查插件的狀態(狀態爲302找到),如果沒有找到(狀態是200-確定),但getcode(),結果總是200! – Vendetta
'urlopen()'可以自動跟蹤重定向,使用'response.geturl()'來查看它是否與你指定的URL不同。 –
好吧,幫助我:) – Vendetta