from urllib import  request as req
url = "http://www.httpbin.org/headers"
# headers = {"User-Agent":"BaiDuSpider"}
# request = req.Request(url,headers=headers)
# res = req.urlopen(request).read().decode()
# print(res)
# headers = {
# 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
# 'Accept-Language':'zh-CN,zh;q=0.9',
# 'Cache-Control':'max-age=0',
# 'Connection':'keep-alive',
# 'Cookie':'BAIDUID=A56424D93AAEF8FA4BC9A42FB823A3D3:FG=1; BIDUPSID=A56424D93AAEF8FA4BC9A42FB823A3D3; PSTM=1571306136; BD_UPN=12314353; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; COOKIE_SESSION=80187_0_7_9_1_2_0_0_6_2_74_0_0_0_99_0_1577153193_0_1577153292%7C9%2326_7_1577065117%7C4; delPer=0; BD_HOME=0; H_PS_PSSID=1438_21123_30211_30284; BD_CK_SAM=1; PSINO=2; H_PS_645EC=c6c13NdgtEPBs25xHIjjlRy%2Br9ObXP15O3%2FG38SswgRzJmrrR8RTaYSpQnw; BDSVRTM=162',
# 'Host':'www.baidu.com',
# 'Sec-Fetch-Mode':'navigate',
# 'Sec-Fetch-Site':'same-origin',
# 'Sec-Fetch-User':'?1',
# 'Upgrade-Insecure-Requests':'1',
# 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
# }
#
# request = req.Request(url,headers=headers)
# opener = req.build_opener()
# try:
#     res = opener.open("https://www.google.com/",timeout=2)
# except:
#     pass
# print(res)
# res = req.urlopen(request).read().decode()
# print(res)
