0

This is the function responsible for finding which links are working and which are not. But this function always returns False value

def link_status_checker(url):
    print url

    try:
        f = urllib2.urlopen(urllib2.Request(url))
        deadLinkFound = True
        print deadLinkFound
    except:
        deadLinkFound = False
        print deadLinkFound

the url's that I am trying to check are as follows

url=["http://91mobiles.com/samsung-galaxy-a9-pro-price-in-india","http://91mobiles.com/samsung-galaxy-j7-2016-price-in-india","http://91mobiles.com/samsung-galaxy-j7-prime-price-in-india"]

1 Answer 1

1

Pass the url string as an argument to urllib2.urlopen() and in the code handling exception, check for the error code 'urllib2.HTTPError' which when raised means the url is not valid.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.