Home
Cloud
Big Data
CI
Install
Samples
Java
Ubuntu
Maven
Archive
Python
|
Using requests
Using requests
Using requests
Installing the package requests:
$ python -m pip install --user requests
Using the package requests:
import requests # import requests module url = 'http://www.mtitek.com' headers = {'Accept': 'text/html'} r = requests.get(url, headers=headers) print(r.status_code) # ==> 200 print(r.headers) # == {'Content-Length': '7657', 'Content-Type': 'text/html', ... } print(r.text)
Reading json pages:
import requests url = 'http://mtitek.com/tutorials/ml/python/file.json' r = requests.get(url) dict_keys = r.json() print(dict_keys.keys()) # ==> dict_keys(['a', 'b', 'c', 'd'])
© 2010-2022
mti
tek