Skip to content

Commit

Permalink
google search cycle until 40 retries or got 100 results
Browse files Browse the repository at this point in the history
  • Loading branch information
deedy5 committed Feb 23, 2024
1 parent e5e32ef commit 315e38b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fake_traffic/fake_traffic.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def acrawl(self):
await page.goto("https://www.google.com", wait_until="load")
await page.fill('textarea[name="q"]', keyword)
await page.press('textarea[name="q"]', "Enter")
while True:
for _ in range(30):
# Check for a popup window and close it
if len(self.browser.pages) > 1:
await self.browser.pages[1].close()
Expand All @@ -103,7 +103,7 @@ async def acrawl(self):
elements = await page.query_selector_all(
"//div[starts-with(@class, 'g ')]//span/a[@href]"
)
if len(elements) > 50:
if len(elements) > 100:
break
result_urls = [await link.get_attribute("href") for link in elements]
logger.info(
Expand Down

0 comments on commit 315e38b

Please sign in to comment.