mirror of
https://git.zavage.net/Zavage-Software/wabot.git
synced 2026-07-21 13:06:08 -06:00
45 lines
1.1 KiB
ReStructuredText
45 lines
1.1 KiB
ReStructuredText
Quickstart
|
|
==========
|
|
|
|
Install
|
|
-------
|
|
|
|
.. code-block:: bash
|
|
|
|
uv add wabot # or: pip install .
|
|
|
|
You also need Firefox or Chromium. Driver binaries (geckodriver /
|
|
chromedriver) are found on PATH or downloaded automatically by Selenium
|
|
Manager.
|
|
|
|
First scrape
|
|
------------
|
|
|
|
.. code-block:: python
|
|
|
|
import wabot
|
|
|
|
class Login(wabot.Page):
|
|
elements = {
|
|
"username": ("el", ("id", "username")),
|
|
"password": ("el", ("id", "password")),
|
|
"submit": ("el", ("id", "submit-btn")),
|
|
}
|
|
|
|
def verify(self):
|
|
return "Login" in self.driver.title
|
|
|
|
def log_in(self, user, password):
|
|
self["username"].set_value(user)
|
|
self["password"].set_value(password)
|
|
return self["submit"].click_and_go()
|
|
|
|
bot = wabot.browser(browser="firefox", headless=True)
|
|
bot.driver.get("https://example.com/login")
|
|
bot.set_page(Login)
|
|
bot.log_in("me", "secret")
|
|
|
|
By default wabot paces itself like a human (multi-second random delays,
|
|
randomized click positions). Pass ``pacing=wabot.NoPacing()`` for full
|
|
speed on sites you trust.
|