import urllib url = "http://www.baidu.com" try: status = urllib.urlopen(url).code print status except: print {'result': 'false', 'msg': 'URL cannot access'}