📜  webdriver antibot - Python (1)

📅  最后修改于: 2023-12-03 15:21:07.399000             🧑  作者: Mango

Webdriver Antibot - Python

Webdriver Antibot is a Python package used for bypassing anti-bot measures on websites that use Selenium WebDriver detection.

Features
  • Automatically add Webdriver Chrome options to the driver instance.
  • Randomize user-agent and viewport sizes.
  • Ability to use custom user-agent and viewport sizes.
  • Supports Chrome and Firefox.
Installation

To install, simply use pip:

pip install webdriver-antibot
Usage
from webdriver_antibot import WebDriverAntiBot

# Create an instance of WebDriverAntiBot
driver = WebDriverAntiBot()

# Navigate to a website
driver.get('https://www.example.com/')

# Do whatever you need to do on the website
# ...

# Close the driver when you're done
driver.quit()
Customizing User-Agent and Viewport Size
from webdriver_antibot import WebDriverAntiBot
from webdriver_antibot.utils import generate_user_agent

# Generate a random user-agent
user_agent = generate_user_agent()

# Create an instance of WebDriverAntiBot with custom user-agent and viewport size
# You can also pass in custom Chrome options or Firefox profile preferences here
driver = WebDriverAntiBot(
    options={"user_agent": user_agent, "viewport_size": (1366, 768)}
)

# Navigate to a website
driver.get('https://www.example.com/')

# Do whatever you need to do on the website
# ...

# Close the driver when you're done
driver.quit()
Contributing

If you find a bug or have a suggestion, feel free to open an issue or pull request on GitHub.

License

Webdriver Antibot is released under the MIT License.