March 2019
Beginner
490 pages
12h 40m
English
Another important request header is the User-Agent header. Any client that communicates using HTTP can be referred to as a user agent. RFC 7231 suggests that user agents should use the User-Agent header to identify themselves in every request. For example, the user agent if you are using the Chrome browser might be as follows:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Also, we can view the user agent used by the urllib Python version:
>>> from urllib.request import Request>>> from urllib.request import urlopen>>> req = Request('http://www.python.org') >>> urlopen(req)<http.client.HTTPResponse object at 0x034AEBF0>>>> req.get_header('User-agent') ...Read now
Unlock full access