You've already forked Curso-lenguaje-python
Update requests exercise
This commit is contained in:
15
python-ofensivo/08_librerias/03_requests_04_json.py
Normal file
15
python-ofensivo/08_librerias/03_requests_04_json.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
|
||||
response = requests.get('https://httpbin.org/get')
|
||||
|
||||
data = response.json()
|
||||
|
||||
if 'headers' in data and 'User-Agent' in data['headers']:
|
||||
|
||||
user_agent = data['headers']['User-Agent']
|
||||
|
||||
else:
|
||||
|
||||
print(f"\n[!] No existe el campo User-Agent en la respuesta\n")
|
||||
Reference in New Issue
Block a user