خرید بک لینک

Vote count: 0

I am trying to implement a function to check if a website is available or there is some error or redirect. Currently the website below give me an HTTP Error 403: Forbidden. My question is, the website is ok, I am expecting a redirect to http://en-uk.frotcom.com/ or similar, but I am catching an error. Something like a false positive.

How can I handle this situation?

import urllib2
def check_website(website):
    TO = 4

    d = {}
    try:
        response = urllib2.urlopen(website, timeout=TO)
    except urllib2.URLError, e:
        if e.args:
            d[website] = e.args
        else:
            d[website] = e
    else:
       if response.url != website:
           d[website] = 'redirect'

    print d #{'http://www.frotcom.com/': HTTPError()}

    retu True

check_website('http://www.frotcom.com/')

asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 13 اسفند 1394 ساعت: 5:17

صفحه بندی