Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Randomly generate the python library of UserAgent (fake- user library)

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

1. Install fake-useragent library:

Pip install fake-useragent

2. Usage:

1. Import fake-useragent library

From fake_useragent import UserAgent

2. Instantiate an object

Ua = UserAgent ()

3. Randomly generate the UserAgent of the IE browser

Ua.ie

U'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/4.0; GTB7.4; InfoPa

Th.3; SV1; .NET CLR 3.1.76908; WOW64; en-US)'

Ua.ie

U'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .N)

ET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)'

Ua.ie

U'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; S

LCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba U

NTRUSTED/1.0'

Ua.ie

U'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; S)

V1; .NET CLR 2.0.50727; WOW64)'

Ua.ie

U'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0'

4. Randomly generate the UserAgent of the firefox browser

Ua.firefox

U'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0'

Ua.firefox

U'Mozilla/5.0 (Windows NT 5.0; rv:21.0) Gecko/20100101 Firefox/21.0'

Ua.firefox

U'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0'

Ua.firefox

U'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0'

Ua.firefox

U'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'

5. Randomly generate the UserAgent of the chrome browser

Ua.chrome

U'Mozilla/5.0 (Macintosh; Intel Mac OS X 10-7-5) AppleWebKit/537.36 (KHTML, like

Gecko) Chrome/27.0.1453.93 Safari/537.36'

Ua.chrome

U'Mozilla/5.0 (Macintosh; Intel Mac OS X 109.3) AppleWebKit/537.36 (KHTML, like)

Gecko) Chrome/35.0.1916.47 Safari/537.36'

Ua.chrome

U'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40

.0.2214.93 Safari/537.36'

Ua.chrome

U'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chr

Ome/41.0.2225.0 Safari/537.36'

Ua.chrome

U'Mozilla/5.0 (Macintosh; Intel Mac OS X 108.2) AppleWebKit/537.17 (KHTML, like)

Gecko) Chrome/24.0.1309.0 Safari/537.17'

6. Randomly generate the UserAgent of the safari browser

Ua.safari

U'Mozilla/5.0 (Windows; U; Windows NT 6.1; de-DE) AppleWebKit/533.20.25 (KHTML

Like Gecko) Version/5.0.3 Safari/533.19.4'

Ua.safari

U'Mozilla/5.0 (Windows; U; Windows NT 6.1; ja-JP) AppleWebKit/533.20.25 (KHTML

Like Gecko) Version/5.0.3 Safari/533.19.4'

Ua.safari

U'Mozilla/5.0 (Windows; U; Windows NT 6.1; sv-SE) AppleWebKit/533.19.4 (KHTML, l

Ike Gecko) Version/5.0.3 Safari/533.19.4'

Ua.safari

U'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU) AppleWebKit/533.18.1 (KHTML, l

Ike Gecko) Version/5.0.2 Safari/533.18.5'

7. Randomly generate the UserAgent of the google browser

Ua.google

U'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.

0.2224.3 Safari/537.36'

Ua.google

U'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.

0.1453.93 Safari/537.36'

Ua.google

U'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chr

Ome/41.0.2226.0 Safari/537.36'

Ua.google

U'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.

0.3319.102 Safari/537.36'

8. Randomly generate the UserAgent of the opera browser

Ua.opera

U'Mozilla/5.0 (Windows NT 6.1; U; de; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 O

Pera 11.01'

Ua.opera

U'Opera/9.80 (Windows NT 6.1; Opera Tablet/15165; U; en) Presto/2.8.149 Version/

11.1'

Ua.opera

U'Opera/9.80 (Windows NT 6.1; U; sv) Presto/2.7.62 Version/11.01'

Ua.opera

U'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; de) Opera 11.51'

Ua.opera

U'Opera/9.80 (Windows NT 6.1; U; pl) Presto/2.7.62 Version/11.00'

9. Randomly generate UserAgent of various browsers

Ua.random

U'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chr

Ome/27.0.1453.93 Safari/537.36'

Ua.random

U'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chr

Ome/30.0.1599.17 Safari/537.36'

Ua.random

U'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chr

Ome/30.0.1599.17 Safari/537.36'

Ua.random

U'Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chr

Ome/41.0.2225.0 Safari/537.36'

Ua.random

U'Mozilla/5.0 (Macintosh; Intel Mac OS X 10: 8) AppleWebKit/537.36 (KHTML, like)

Gecko) Chrome/32.0.1664.3 Safari/537.36'

Ua.random

U'Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko)

Chrome/29.0.1547.57 Safari/537.36'

Ua.random

U'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)

) Chrome/32.0.1667.0 Safari/537.36'

Ua.random

U'Mozilla/5.0 (X11; Ubuntu; Linux x8634; rv:24.0) Gecko/20100101 Firefox/24.0'

Ua.random

U'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40

.0.2214.93 Safari/537.36'

Ua.random

U'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2

.net CLR 2.0.50727; InfoPath.3; .NET 4.0C; .NET 4.0E; .NET CLR 3.5.30729; .NET CLR

3.0.30729; MS-RTC LM 8)'

Third, check the fake-useragent version

1. Use the pip list command to view the fake-useragent version

(scrapytest) F:\ python-virtualenv\ scrapytest\ Scripts > pip list

Attrs (17.3.0)

Automat (0.6.0)

Certifi (November 5, 2017)

Cffi (1.11.2)

Chardet (3.0.4)

Constantly (15.1.0)

Cryptography (2.1.3)

Cssselect (1.0.1)

Enum34 (1.1.6)

Fake-useragent (0.1.8)

Hyperlink (17.3.1)

Idna (2.6)

Visit https://fake-useragent.herokuapp.com/browsers/0.1.8 to view useragent library

4. User- Agent Library

Https://fake-useragent.herokuapp.com/browsers/0.1.4

Displayed in json format, you can copy the content to the following URL for json view display

Https://www.bejson.com/jsonviewernew/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report