我正在检查网站列表,看看他们是否重定向,但我为我知道有302代码的网站获取了HTTP代码200。我做错了吗?
import urllib2
with open('list.txt', 'r') as f:
sites = f.readlines()
for url in sites:
try:
connection = urllib2.urlopen(url)
print connection.getcode()
connection.close()
except urllib2.HTTPError, e:
print e.getcode()