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)

 

你可能感兴趣的:(test)