-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