Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
playwright-network-spy
Advanced tools
π₯ A powerful tool for crawling any website on Earth with infinite scrolling, using Playwright.
Playwright Network Spy is a powerful Python library that simplifies network capturing when using Playwright. It allows you to easily capture and retrieve information from any website on the internet, even in modern web environments that heavily utilize infinite scrolling and REST APIs. ππ»
Crawl from network responses, not from unstable DOMs!
You can install Playwright Network Spy using pip:
pip install playwright-network-spy
Here's a simple example of how to use Playwright Network Spy to capture and print SVG images from a website
from typing import Any, Dict, Tuple
from playwright.async_api import Page, Response, async_playwright
from playwright_network_spy.spy import NetworkSpy
async def capture_and_print_svg_from_cloudflare(page: Page) -> None:
async def _is_svg(response: Response) -> bool:
return response.url.endswith(".svg")
spy = NetworkSpy(page, _is_svg)
await page.goto("https://cloudflare.com")
responses = spy.get_new_responses()
print(responses) # [<Response url='https://www.cloudflare.com/img/privacyoptions.svg'>, ...]
async def main(*args: Tuple[Any, ...], **kwargs: Dict[str, Any]) -> None:
async with async_playwright() as playwright:
webdriver = playwright.chromium
async with await webdriver.launch() as browser:
async with await browser.new_page() as page:
await capture_and_print_svg_from_cloudflare(page)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Playwright Network Spy is designed for modern websites that are complex to parse from the DOM. Instead of parsing, simply capture the entire JSON response and utilize it. π
For more detailed examples, you can refer to the Example in our GitHub repository.
For detailed documentation and more examples, please visit our official documentation. Contributing π€ We welcome contributions from the community! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on our GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for more information.
FAQs
π₯ A powerful tool for crawling any website on Earth with infinite scrolling, using Playwright.
We found that playwright-network-spy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 0 open source maintainers 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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.