, how do i use urllib to see if a website is 404 or 200 in Python Programming Language?

editAnswer

reportReport

Answer(s) available: 1

Yashvasin Mehra

, Chiropractor, Audio Invoices Repairs

"

The getcode() method (Added in python2.6) returns the HTTP status code that was sent with the response, or None if the URL is no HTTP URL.

"
>>> a=urllib.urlopen('http://www.google.com/asdfsf')"
>>> a.getcode()"
404"
>>> a=urllib.urlopen('http://www.google.com/')"
>>> a.getcode()"
200"
"

thumb_upUpvote19

smsComment

reportReport