osn-bas is a Python library for browser automation and web scraping. It supports Chrome, Firefox, Edge, and Yandex, providing a consistent API for managing browser sessions, options, and common actions like scrolling, element interaction, and JavaScript execution. It also facilitates remote webdriver control.
Project description
osn-bas: A Python Library for Browser Automation
osn-bas simplifies interaction with web browsers for scraping and automation tasks. It currently supports Chrome, Firefox, Edge, and Yandex browsers, providing a consistent interface for managing browser sessions, handling options, and performing common actions.
Key Features:
- Cross-Browser Support: Seamlessly work with Chrome, Firefox, Edge, and Yandex browsers using a unified API.
- Remote WebDriver Control: Connect to and manage existing browser sessions remotely.
- Headless Browsing: Execute tasks discreetly in the background without a visible browser window.
- Proxy Support: Integrate proxies for managing network requests.
- User Agent Spoofing: Customize the user agent string for various browser impersonations.
- Window Management: Control window size, position, and manage multiple tabs/windows.
- Simplified API: Perform common actions like scrolling, hovering, finding elements, and executing JavaScript.
Installation:
-
With pip:
pip install osn-bas
-
With git:
pip install git+https://github.com/oddshellnick/osn-bas.git
API Reference:
- BaseDriver: Provides fundamental classes like
EmptyWebDriver,BrowserOptionsManager,BrowserStartArgs, andBrowserWebDriverfor core browser management functionality. - ChromeDriver/EdgeDriver/FirefoxDriver/YandexDriver: Contains specific implementations for each browser, including options management, startup argument handling, and remote webdriver connection classes.
- browsers_handler: Includes helper classes like
WindowRectfor managing window dimensions andget_installed_browsers/get_browser_versionfor retrieving system browser information.
Modules Overview:
- EmptyWebDriver: A base class offering essential methods for interacting with a webdriver.
- BrowserOptionsManager: Base class for managing browser-specific options. Subclassed for each browser type.
- BrowserStartArgs: Base class for managing browser startup arguments. Subclassed for each browser.
- BrowserWebDriver: Base class for managing the lifecycle of a webdriver instance. Subclassed for each browser.
- Chrome(Remote)WebDriver, Edge(Remote)WebDriver, Firefox(Remote)WebDriver, Yandex(Remote)WebDriver: Concrete implementations for managing local and remote sessions for each browser.
This library aims to simplify browser automation in Python. Contributions and feedback are welcome!
Usage Examples:
Starting a Chrome Webdriver:
from osn_bas.webdrivers.Chrome import ChromeWebDriver
from osn_bas.utilities import WindowRect
webdriver = ChromeWebDriver(webdriver_path="/path/to/chromedriver", window_rect=WindowRect(0, 0, 800, 600))
webdriver.start_webdriver(headless_mode=True)
webdriver.search_url("https://www.example.com")
# ... perform actions ...
webdriver.close_webdriver()
Connecting to a Remote Chrome Instance:
from osn_bas.webdrivers.Chrome import ChromeWebDriver
from osn_bas.webdrivers.Chrome import ChromeRemoteWebDriver
webdriver = ChromeWebDriver(webdriver_path="/path/to/chromedriver")
webdriver.start_webdriver()
command_executor, session_id = webdriver.get_vars_for_remote()
remote_webdriver = ChromeRemoteWebDriver(command_executor, session_id)
remote_webdriver.create_driver()
# ...Interact with the remote browser...
remote_webdriver.close_webdriver()
Future Notes
osn-bas is under active development. Planned future enhancements include support for additional browsers, advanced interaction features, and improved handling of dynamic web content. Contributions and suggestions for new features are welcome! Feel free to open issues or submit pull requests on the project's repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osn_bas-1.0.0.tar.gz.
File metadata
- Download URL: osn_bas-1.0.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
461f02ec702af522ec4de3e3961f709bd43b9d23f5b4ce8aa82a855cf012f9d7
|
|
| MD5 |
bc507818ea0ef717976dd8353dcee8bd
|
|
| BLAKE2b-256 |
e6482e19eada2326b36938c674d4706b3601cabff25303fc4455905b2071d28c
|
Provenance
The following attestation bundles were made for osn_bas-1.0.0.tar.gz:
Publisher:
python-publish.yml on oddshellnick/osn-bas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osn_bas-1.0.0.tar.gz -
Subject digest:
461f02ec702af522ec4de3e3961f709bd43b9d23f5b4ce8aa82a855cf012f9d7 - Sigstore transparency entry: 179329458
- Sigstore integration time:
-
Permalink:
oddshellnick/osn-bas@60dbded78e9cc1b04311289dbcfddca89c2f8f86 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/oddshellnick
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@60dbded78e9cc1b04311289dbcfddca89c2f8f86 -
Trigger Event:
release
-
Statement type:
File details
Details for the file osn_bas-1.0.0-py3-none-any.whl.
File metadata
- Download URL: osn_bas-1.0.0-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eecb589e2814e1efe2d1209c4d3085ccaba8046cbf1b84648a452793ea233e8c
|
|
| MD5 |
60114f5e8ea58477a818b89fe1bee8e5
|
|
| BLAKE2b-256 |
a33a6c43451bf4e8c81cd407973c761c01c27b1ad0ca64ed53a881afcfc150fa
|
Provenance
The following attestation bundles were made for osn_bas-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on oddshellnick/osn-bas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osn_bas-1.0.0-py3-none-any.whl -
Subject digest:
eecb589e2814e1efe2d1209c4d3085ccaba8046cbf1b84648a452793ea233e8c - Sigstore transparency entry: 179329461
- Sigstore integration time:
-
Permalink:
oddshellnick/osn-bas@60dbded78e9cc1b04311289dbcfddca89c2f8f86 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/oddshellnick
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@60dbded78e9cc1b04311289dbcfddca89c2f8f86 -
Trigger Event:
release
-
Statement type: