[pypi] random-user-agent
2021. 11. 18. 20:57ㆍ개발자료/Python
반응형
스크래핑, 크롤링시 서버를 속이기위해 여러가지 UserAgent가 필요할때가 있다.
이때 사용하면 좋을것 같다.
● Install
pip install random-user-agent
● Usage
from random_user_agent.user_agent import UserAgent
from random_user_agent.params import SoftwareName, OperatingSystem
# you can also import SoftwareEngine, HardwareType, SoftwareType, Popularity from random_user_agent.params
# you can also set number of user agents required by providing `limit` as parameter
software_names = [SoftwareName.CHROME.value]
operating_systems = [OperatingSystem.WINDOWS.value, OperatingSystem.LINUX.value]
user_agent_rotator = UserAgent(software_names=software_names, operating_systems=operating_systems, limit=100)
# Get list of user agents.
user_agents = user_agent_rotator.get_user_agents()
# Get Random User Agent String.
user_agent = user_agent_rotator.get_random_user_agent()
https://pypi.org/project/random-user-agent/
반응형
'개발자료 > Python' 카테고리의 다른 글
[pypi] chromedriver-autoinstaller (0) | 2021.12.08 |
---|---|
fake-useragent (0) | 2021.04.29 |
경로(Path), 파일명, 확장자 조작 함수 (0) | 2021.03.12 |
Selenium (0) | 2020.12.14 |
pyserial - Python Serial Port Extension (0) | 2020.10.15 |