fake-useragent替代库anole
安装使用:pip install anole
下面为官网译文:
Project description
项目描述
Like a anole, fake everything.
像小丑一样,假装一切。
Currently support user agent and name fake, other will be coming soon.
目前支持用户代理和假名,其他将很快到来。
Thanks for use.
谢谢你的使用
How to use
如何使用
from anole import UserAgent
# Suppose this is the request headers
headers = {
"referer": "https://leesoar.com"
}
user_agent = UserAgent()
user_agent.fake(headers)
It will check if there is “user-agent” in headers. If not, “user-agent” will update with random.
它将检查标题中是否有“user-agent”。如果没有,“user-agent”将随机更新。
from anole import Name
name = Name()
name.fake() # Whole name's length is between 2 and 3.
name.fake(length=2) # You can specify the length of the name.
name.fake(surname="李") # And you can specify the surname.
假名
Use as fake_useragent
作为fake_useragent使用
from anole import UserAgent
user_agent = UserAgent()
user_agent.random
# or user_agent.chrome
# or other browsers