Package: fake-useragent-migs
info:Up to date simple useragent faker with real world databaseFeaturesgrabs up to dateuseragentfromuseragentstring.comrandomize with real world statistic viaw3schools.comInstallationpipinstallfake-useragentUsagefromfake_useragentimportUserAgentua=UserAgent()ua.ie# Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US);ua.msie# Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)'ua['Internet Explorer']# Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)ua.opera# Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11ua.chrome# Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2'ua.google# Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1290.1 Safari/537.13ua['google chrome']# Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11ua.firefox# Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1ua.ff# Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1ua.safari# Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25# and the best one, random via real world browser usage statisticua.randomNotesfake-useragentstore collected data at your os temp dir, like/tmpIf You want to update saved database just:fromfake_useragentimportUserAgentua=UserAgent()ua.update()If You don’t want cache database or no writable file system:fromfake_useragentimportUserAgentua=UserAgent(cache=False)Sometimes,useragentstring.comorw3schools.comchanges their html, or down, in such casefake-useragentusesherokufallbackIf You don’t want to use hosted cache server (version 0.1.5 added)fromfake_useragentimportUserAgentua=UserAgent(use_cache_server=False)In very rare case, if hosted cache server and sources will be
unavailablefake-useragentwont be able to download data: (version 0.1.3 added)fromfake_useragentimportUserAgentua=UserAgent()# Traceback (most recent call last):#   ...# fake_useragent.errors.FakeUserAgentError# You can catch it viafromfake_useragentimportFakeUserAgentErrortry:ua=UserAgent()exceptFakeUserAgentError:passIf You will try to get unknown browser: (version 0.1.3 changed)fromfake_useragentimportUserAgentua=UserAgent()ua.best_browser# Traceback (most recent call last):#   ...# fake_useragent.errors.FakeUserAgentErrorYou can completely disable ANY annoying exception with addingfallback: (version 0.1.4 added)importfake_useragentua=fake_useragent.UserAgent(fallback='Your favorite Browser')# in case if something went wrong, one more time it is REALLY!!! rare caseua.random=='Your favorite Browser'Want to control location of data file? (version 0.1.4 added)importfake_useragent# I am STRONGLY!!! recommend to use version suffixlocation='/home/user/fake_useragent%s.json'%fake_useragent.VERSIONua=fake_useragent.UserAgent(path=location)ua.randomIf you need to safe some attributes from overriding them in UserAgent by__getattr__method
usesafe_attrsyou can pass there attributes names.
At least this will prevent you from raising FakeUserAgentError when attribute not found.For example, when using fake_useragent withinjectionsyou need to:importfake_useragentua=fake_useragent.UserAgent(safe_attrs=('__injections__',))Please, do not use if you don’t understand why you need this.
This is magic for rarely extreme case.Experiencing issues???Make sure that You using latest version!!!pipinstall-Ufake-useragentCheck version via python console: (version 0.1.4 added)importfake_useragentprint(fake_useragent.VERSION)And You are always welcome to postissuesPlease do not forget mention version that You are usingTestspip install tox
toxChangelog0.1.11 October 4, 2018moveds3 + cloudfrontfallback toheroku.com, cuz someone from Florida did ~25M requests last month0.1.10 February 11, 2018Minor fix docscloudfronturl0.1.9 February 11, 2018fixw3schools.comrenamedIE/EdgetoEdge/IEmovedheroku.comfallback tos3 + cloudfrontstop testing Python3.3 and pypy0.1.8 November 2, 2017fixuseragentstring.comCan't connect to local MySQL server through socket0.1.7 April 2, 2017fix broken README.rst0.1.6 April 2, 2017fixes buguse_cache_serverdo not affected anythingw3schools.commoved tohttpsverify_ssloptions added, by default it isTrue(urllib.urlopenssl context for Python 2.7.9- and 3.4.3- is not supported)0.1.5 February 28, 2017addedua.edgealias to Internet Explorerw3schools.com starts displayingEdgestatisticPython 2.6 is not tested anymoreuse_cache_serveroption addedIncreasedfake_useragent.settings.HTTP_TIMEOUTto 5 seconds0.1.4 December 14, 2016Added custom data file location supportAddedfallbackbrowser support, in case of unavailable data sourcesAdded aliasfake_useragent.FakeUserAgentforfake_useragent.UserAgentAdded aliasfake_useragent.UserAgentErrorforfake_useragent.FakeUserAgentErrorReducedfake_useragent.settings.HTTP_TIMEOUTto 3 secondsStarted migration to new data file formatSimplified a lot 4+ years out of date codeBetter thread/greenlet safetyAdded verbose loggingAddedsafe_attrsfor prevent overriding by__getattr__0.1.3 November 24, 2016Added hosted data file, when remote services is unavailableRaisesfake_useragent.errors.FakeUserAgentErrorin case when there is not way to download dataRaisesfake_useragent.errors.FakeUserAgentErrorinstead ofNonein case of unknown browserAddedgevent.sleepsupport ingeventpatched environment when trying to download dataX.X.X xxxxxxx xx, xxxxxxxxx ?????AuthorsYou can visitauthors page