Python/requests

From Fundamental Ramen
< Python
Revision as of 09:59, 9 October 2019 by Tacoball (talk | contribs)
Jump to navigation Jump to search
import requests
from requests.exceptions import ConnectionError

try:
    resp = requests.get('https://duckduckgo.com/')
    if resp.status_code == 200:
        print(resp.text)
    else:
        print(resp.status_code)
except ConnectionError as ex:
    print(ex)