[Answered ]-How to validate JSON with simplejson

0👍

You should be able to tell that you recieved a 404, because the response code was not 200. That is:

import urllib
resp = urllib.urlopen('http://example.com/')

if resp.getcode() == 200:
    rejoice()
if resp.getcode() == 404:
    sulk()

2👍

Find the first non-whitespace character. If it’s “<” then you have HTML.

Also, check the content type header and HTTP status code.

Leave a comment