From c7e0c576a0e1b64b6c13087e0a6ed09654299d5c Mon Sep 17 00:00:00 2001 From: deedy5 <65482418+deedy5@users.noreply.github.com> Date: Fri, 23 Feb 2024 23:53:32 +0300 Subject: [PATCH] remove install playwright using subprocess.run --- fake_traffic/fake_traffic.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/fake_traffic/fake_traffic.py b/fake_traffic/fake_traffic.py index e8ecc41..22f2838 100644 --- a/fake_traffic/fake_traffic.py +++ b/fake_traffic/fake_traffic.py @@ -1,22 +1,11 @@ import asyncio import logging -import subprocess from playwright.async_api import async_playwright from playwright_stealth import stealth_async logger = logging.getLogger("__name__") -# playwright install chromium -res = subprocess.run( - "playwright install chromium", - shell=True, - check=True, - capture_output=True, - text=True, -) -logger.info(res.stdout) - class FakeTraffic: def __init__( @@ -26,7 +15,6 @@ def __init__( category="h", headless=True, tabs=3, - ): """Internet traffic generator. Utilizes real-time google search trends by specified parameters. country = country code ISO 3166-1 Alpha-2 code (https://www.iso.org/obp/ui/), @@ -105,7 +93,9 @@ async def acrawl(self): ) if len(elements) > 100: break - result_urls = [await link.get_attribute("href") for link in elements] + result_urls = [ + await link.get_attribute("href") for link in elements + ] logger.info( f"google_search() {keyword=} GOT {len(result_urls)} results" ) @@ -120,6 +110,7 @@ async def acrawl(self): def crawl(self): asyncio.run(self.acrawl()) + if __name__ == "__main__": fake_traffic = FakeTraffic( country="US",