load_user_agent_strings
- pyhelpers.ops.load_user_agent_strings(shuffled=False, flattened=False, update=False, verbose=False)
Load user-agent strings of popular browsers.
The current version collects a partially comprehensive list of user-agent strings for Chrome, Firefox, Safari, Edge, Internet Explorer and Opera.
- Parameters
shuffled (bool) – whether to randomly shuffle the user-agent strings, defaults to
False
flattened (bool) – whether to make a list of all available user-agent strings, defaults to
False
update (bool) – whether to update the backup data of user-agent strings, defaults to
False
verbose (bool or int) – whether to print relevant information in console, defaults to
False
- Returns
a dictionary of user agent strings for popular browsers
- Return type
dict or list
Examples:
>>> from pyhelpers.ops import load_user_agent_strings >>> uas = load_user_agent_strings() >>> list(uas.keys()) ['Chrome', 'Firefox', 'Safari', 'Edge', 'Internet Explorer', 'Opera'] >>> type(uas['Chrome']) list >>> uas['Chrome'][0] 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/... >>> uas_list = load_user_agent_strings(shuffled=True, flattened=True) >>> type(uas_list) list >>> uas_list[0] # a random one 'Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.792.0 Saf...
Note
The order of the elements in
uas_list
may be different every time we run the example asshuffled=True
.