📜  urllib.request 标头 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:12.363000             🧑  作者: Mango

代码示例1
try:
    from urllib.request import Request, urlopen  # Python 3
except ImportError:
    from urllib2 import Request, urlopen  # Python 2

req = Request('http://api.company.com/items/details?country=US&language=en')
req.add_header('apikey', 'xxx')
content = urlopen(req).read()

print(content)