testUrl

def ConnectTest(url):
    try:
        response = requests.get(url)
        return response.status_code
    except requests.exceptions.ConnectionError:
        print("ConnectionError")
    except requests.exceptions.HTTPError:
        print("HTTPError")
    except requests.exceptions.Timeout:
        print("Timeout")
    except Exception,e:
        print str(e)

 

posted @ 2014-04-26 23:14  r3call  阅读(324)  评论(0编辑  收藏  举报