Anti reptile camouflage mechanism ---- User-Agent of the fake-useragent

First, anti-climb today to explain the mechanism of camouflage UserAgent

first: with pip install fake_useragent in cmd command line

pip install fake-useragent

use:

    from fake_useragent UserAgent Import
    Import Random
     
    fake_ua UserAgent = () # construct UserAgent () subject
    headers = { 'user-agent': fake_ua.random} # randomly made by the user agent random.

Get each browser-userAgent Fake

    from fake_useragent Import UserAgent
    UA UserAgent = ()
    #ie Agent Browser User
    Print (ua.ie)
     
    #opera browser
    Print (ua.opera)
     
    #chrome browser
    print (ua.chrome)
     
    #firefox browser
    Print (ua.firefox)
     
    #safri browser
    Print (ua.safari)
     
    # the most common way to
    # write reptiles most practical is free to change the headers, must be random. Support random header generation request
    Print (ua.random)
    Print (ua.random)
    Print (ua.random)

 

The second: There are many online Baidu search, copy number using

attached:

How to view the version of the fake-useragent?

There are two methods

first:

Baidu pypi fake-useragent see the current version, because no little data updated version

found version number, type in the address bar version https://fake-useragent.herokuapp.com/browsers/ No. For example, now the latest is: https: //fake-useragent.herokuapp.com/browsers/0.1.11

you'll see all the useragent, as shown:

second:

when you install python fake-useragent, enter python, pip list can be viewed using the command corresponding version
----------------

original link: https: //blog.csdn.net/ITYTI/article/details/83757118

Guess you like

Origin www.cnblogs.com/yidanda888/p/12148687.html