Получить запросы от Python
import requests
response = requests.get('<api-endpoint>')
response.raise_for_status()
data = response.json()
print(data)
Tejas Naik
import requests
response = requests.get('<api-endpoint>')
response.raise_for_status()
data = response.json()
print(data)
import requests
url = 'https://codegrepper.com/'
response = requests.get(url)
print('URL: ', response.url)
print('Status code: ', response.status_code)
print('HTTP header: ', response.headers)
# pip install requests
import requests
req = requests.get('<url here>', 'html.parser')
print(req.text)
import requests
r = requests.get('https://api.github.com', auth=('user', 'pass'))
print r.status_code
print r.headers['content-type']
Url = "https://"
r = requests.get( Url )
data = r.json()
Raise an exception if a request is unsuccessful
import requests
url = "http://mock.kite.com/status/404"
r = requests.get(url)
try:
r.raise_for_status()
except requests.exceptions.HTTPError as e:
print e
OUTPUT
404 Client Error: NOT FOUND