Skip to main content

PySelenScrapr

Here is a sample code for a good scraper logic with some validation logic. It helps to build a good scraper with validation steps and repeat logic.

Installation

pip install pyselenscrapr

Usage

from pyselenscraper.ScrapingBot import ScrapingBot, TakeScreenshotModes
from pyselenscraper.ScrapingLogic import ScrapingLogic
from pyselenscraper.ScrapingStep import ScrapingStep, ScrapingStepInterval, ScrapingStepErrorHandling

...
# Initialize selenium driver
driver = webdriver.Remote("http://localhost:4444/wd/hub", options=ff_options)
...

robot = ScrapingBot(driver, take_screenshots_mode=TakeScreenshotModes.Always)

try:

   search_command = "wikipedia matrix movies"

   robot.add_step(ScrapingStep("Check if there is a visible 'Accept all' or 'decline all' button",
                               lambda l: l.get_best_element("//button//div[contains(text(), 'All')]").click(),
                               interval=ScrapingStepInterval.BeforeAnyStep,
                               error_handling=ScrapingStepErrorHandling.Ignore,
                               can_execute=lambda l: l.current_url and "google" in l.current_url and l.is_visible("//button//div[contains(text(), 'All')]"),
                               was_executed=lambda l: not l.is_visible("//button//div[contains(text(), 'All')]"),),
                  step_group="default")

   ...
   # Your scraper Logic here
   ...

   finished_success = robot.run()

   if finished_success:
       print("The robot finished successfully")
   else:
       print("The robot did not finish successfully")

except Exception as e:
   log.error(e)
finally:
   driver.quit()

Documentation

The documentation is available at https://pyselenscrapr.readthedocs.io/.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Metadata

Release files for pyselenscrapr 0.0.81

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyselenscrapr 0.0.81
File Size Uploaded Provenance Actions
pyselenscrapr-0.0.81.tar.gz 15.6 kB Without provenance Details for pyselenscrapr-0.0.81.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyselenscrapr 0.0.81
File Interpreter ABI Platform Actions
pyselenscrapr-0.0.81-py3-none-any.whl Python 3 none any Details for pyselenscrapr-0.0.81-py3-none-any.whl

Total release size: 29.3 kB

Release files / pyselenscrapr-0.0.81.tar.gz

Download URL pyselenscrapr-0.0.81.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0b94dccb614fc0652d2f37b5f055ee64d7dda7e216754ead4ae38bf17528bcd4
BLAKE2b-256 checksum
How to use checksums
0b35d723e0bffd3314626ecec4f3ba90c0e598df406e6788d60b425a94653471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.14

Release files / pyselenscrapr-0.0.81-py3-none-any.whl

Download URL pyselenscrapr-0.0.81-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3faace5e72a66bf22b429878c69835924b8fa712606516f7bad0fe8261f5b5c1
BLAKE2b-256 checksum
How to use checksums
a9a53eabc40696eaf595fb5da082854c08e1ea7bf72551ca09bae6565462e276
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.14

Security for pyselenscrapr 0.0.81

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page