get_user_agent_string
- pyhelpers.ops.get_user_agent_string(fancy=None, **kwargs)[source]
Get a random user-agent string of a certain browser.
- Parameters:
fancy – name of a preferred browser, defaults to
None
; options include'Chrome'
,'Firefox'
,'Safari'
,'Edge'
,'Internet Explorer'
and'Opera'
; iffancy=None
, the function returns a user-agent string of a randomly-selected browser among all the available optionskwargs – [optional] parameters of the function
pyhelpers.ops.get_user_agent_strings()
- Type:
fancy: None | str
- Returns:
a user-agent string of a certain browser
- Return type:
str
Examples:
>>> from pyhelpers.ops import get_user_agent_string >>> # Get a random user-agent string >>> uas_0 = get_user_agent_string() >>> uas_0 'Opera/7.01 (Windows 98; U) [en]' >>> # Get a random Chrome user-agent string >>> uas_1 = get_user_agent_string(fancy='Chrome') >>> uas_1 'Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.9...
Note
In the above examples, the returned user-agent string is random and may be different every time of running the function.