0

I'm checking a list of sites to see if they redirect but I'm getting a HTTP code 200 for sites that I know have a 302 code. Am I doing something wrong?

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()
Anthony
  • 3
  • 5

0 Answers0