Skip to content

Commit

Permalink
google_trends(): parse news urls into urls_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
deedy5 committed Feb 17, 2024
1 parent 8a79ba1 commit c7c4c42
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fake_traffic/fake_traffic.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def google_trends(self):
elements = self.page.query_selector_all("//div[@class='title']")
trends = [x for e in elements for x in e.inner_text().split(" • ")]
logging.info(f"google_trends() GOT {len(trends)} trends")

for e in elements:
e.click()
self.page.wait_for_selector("//div[@class='carousel-wrapper']")
related_urls_elements = self.page.query_selector_all("//div[@class='carousel-wrapper']//a")
related_urls = [link.get_attribute("href") for link in related_urls_elements]
self.urls_queue.extend(related_urls)
return trends

def parse_urls(self, page, base_url):
Expand Down

0 comments on commit c7c4c42

Please sign in to comment.