
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
tq-recursive-scroll-scrape
Advanced tools
Python library for automating scrolling and downloading web pages via Selenium. Scrolling and downloading functionality is provided by the tq-scroll-scrape package.
Recursive-Scroll-Scraper provides the ability to download a paginated site, i.e. starting at the root page, getting the next page url, downloading that page, and so on until the end is reached.
sample_app.py
demonstrates this use case using the Trulia real estate listings site.
Download ChromeDriver from https://chromedriver.chromium.org/downloads. Choose the version that matches the Chrome browser running on your system.
Download GeckoDriver for Firefox from https://github.com/mozilla/geckodriver/releases.
Install the package by running pip install tq-recursive-scroll-scrape
.
Here is sample code demonstrating how to crawl a paginated site.
from tq_recursive_scroll_scrape.recursive_scroll_and_scrape import RecursiveScrollScrape
root_url = "https://www.trulia.com"
first_url = f"{root_url}/WA/Renton"
driver_path = "PATH TO DRIVER EXECUTABLE"
scroll_scraper = RecursiveScrollScrape(driver_path)
Provide a callback containing the logic to get the next page links. Since this function is called recursively, be sure to provide a terminating condition to avoid infinite loops.
from bs4 import BeautifulSoup
from typing import Optional
def get_next_url(content: str) -> Optional[str]:
soup = BeautifulSoup(content, "html.parser")
links = [a for a in soup.find_all("a")
if a.get("aria-label")
and "Next" in a.get("aria-label")]
# Terminates recursion if the last page is reached.
if len(links) == 0:
return None
next_url = f"{root_url}{links[0].get('href')}"
return next_url
Provide an optional callback containing the logic to perform after each page download such as saving the content to disk.
def on_after_download(content: str):
with open("some_file.html", "w", encoding="utf-8") as file:
file.write(content)
scroll_scraper.download(first_url, on_after_download, get_next_url)
Refer to the tq-scroll-scrape documentation for details on controlling scroll and download options. For example, the default wait time between scrolls is two seconds but can be changed. By default, the entire page is scrolled at once but can be scrolled by a specific number of pixels if desired.
FAQs
recursive-scroll-scrape module.
We found that tq-recursive-scroll-scrape demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.