Skip to content

Commit

Permalink
remove install playwright using subprocess.run
Browse files Browse the repository at this point in the history
  • Loading branch information
deedy5 committed Feb 23, 2024
1 parent 054089c commit c7e0c57
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions fake_traffic/fake_traffic.py
Original file line number Diff line number Diff line change
@@ -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__(
Expand All @@ -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/),
Expand Down Expand Up @@ -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"
)
Expand All @@ -120,6 +110,7 @@ async def acrawl(self):
def crawl(self):
asyncio.run(self.acrawl())


if __name__ == "__main__":
fake_traffic = FakeTraffic(
country="US",
Expand Down

0 comments on commit c7e0c57

Please sign in to comment.