Skip to main content

Scroll-Scraper

Python library for automating scrolling and downloading web pages via Selenium. This is especially useful for pages that utilize infinite scrolling.

Usage

Using ChromeDriver

Download ChromeDriver from https://chromedriver.chromium.org/downloads. Choose the version that matches the Chrome browser running on your system.

Using GeckoDriver for Firefox

Download GeckoDriver for Firefox from https://github.com/mozilla/geckodriver/releases.

Install Package

Install the package by running pip install tq-scroll-scrape.

Use the Package

Here is sample code demonstrating how to download a page:

from tq_scroll_scrape.scroll_and_scrape import ScrollAndScrape

url = "https://www.espn.com/"
driver_path = "{PATH TO DRIVER EXECUTABLE}"
scroll_scraper = ScrollAndScrape(driver_path)
scroll_scraper.download(url)
scroll_scraper.driver.close()
scroll_scraper.driver.quit()

This library will scroll the page until it reaches the end. The scroll height can be controlled by passing the scroll_by kwarg. If omitted the value of document.body.scrollHeight is used.

To give items the chance to render, the library will wait before scrolling again. The wait time can be controlled via the sleep_after_scroll_seconds parameter. If omitted, the default value is two seconds.

The example below scrolls the page by 500 pixels, waiting 5 seconds between each scroll.

from tq_scroll_scrape.scroll_and_scrape import ScrollAndScrape

driver_path = "{PATH TO DRIVER EXECUTABLE}"
scroll_scraper = ScrollAndScrape(driver_path)
downloader.download(url, sleep_after_scroll_seconds=5, scroll_by=500)
downloader.driver.close()
downloader.driver.quit()

Post-download Processing

The download function accepts a callback that executes after the page is downloaded. The page source is passed into the callback. The example below saves the downloaded page to an html file.

from tq_scroll_scrape.scroll_and_scrape import ScrollAndScrape


def save_file(source: str):
    with open("espn.html", "w") as file:
        file.write(source)


url = "https://www.espn.com/"
driver_path = "{PATH TO DRIVER EXECUTABLE}"
scroll_scraper = ScrollAndScrape(driver_path)
downloader.download(url, save_file)
downloader.driver.close()
downloader.driver.quit()

Metadata

Release files for tq-scroll-scrape 4.0

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

Built distribution (wheel)

Table of built distributions (wheels) for tq-scroll-scrape 4.0
File Interpreter ABI Platform Actions
tq_scroll_scrape-4.0-py3-none-any.whl Python 3 none any Details for tq_scroll_scrape-4.0-py3-none-any.whl

Release files / tq_scroll_scrape-4.0-py3-none-any.whl

Download URL tq_scroll_scrape-4.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4eabb3035dfba76d222526aba1964b0d6e9ea5b6ea6140bf1695c74dfc139cd
BLAKE2b-256 checksum
How to use checksums
370fb07d8c08c4e7c6beb379df488723d9961d6462cab1e29b6a321adfd18d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.9

Security for tq-scroll-scrape 4.0

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