console
$ pip install requests
sample.py
import requests
request_url = 'http://google.com'
request_params = {'param1': 1, 'param2': 2}
request = requests.get(request_url, params=request_params)
if request.status_code == 200:
print("\n", request.encoding)
print("\n", request.headers['content-type'])
print("\n", request.text)
console
Shift_JIS
text/html; charset=Shift_JIS
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="ja">...</html>
Recommended Posts