Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- url = 'http://example.com'
- data = {"request":"login", "data":{"login":"user","password":"pwd"}}
- response = requests.post(url, data=data)
- #headers = {"Content-Type":"application/json"}
- if response.ok and 'application/json' in response.headers.get('content-type'):
- print(response.json().keys())
- #Пример с работающим ответом в формате json()
- import requests
- response = requests.get('https://api.github.com/some/endpoint')
- if 'application/json' in response.headers.get('content-type'):
- print(response.json().keys())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement