Skip to content

Commit

Permalink
Update fake_traffic.py
Browse files Browse the repository at this point in the history
  • Loading branch information
deedy5 authored Aug 16, 2021
1 parent 73ff569 commit 1e6f220
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions fake_traffic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from random import uniform, choice, randint
from random import uniform, choice, randint, sample
from datetime import datetime
from time import sleep

import requests
Expand All @@ -7,12 +8,10 @@
from google_searching import ggl
from google_trends import realtime_trends


__version__ = 0.3

__version__ = 0.4

def real_trends(country='US', language='en-US'):
trends = realtime_trends(country=country, language=language, category='h', num_results=15)
trends = realtime_trends(country=country, language=language, category='h', num_results=20)
return trends

def get_url(url):
Expand Down Expand Up @@ -68,10 +67,11 @@ def recursive_browse(url, depth=randint(0, 5)):
def fake_traffic(country='US', language='en-US'):
print('*** Fake traffic ***')
while True:
print(datetime.now())
print(f'\n------GET TRENDS IN {country=}------')
trends = real_trends(country=country, language=language)
trend = choice(trends)
word = ' '.join(trend['entity_names'][:2])
word = ' '.join(sample(trend['entity_names'], 2))
article_urls = trend['article_urls']
print(f"*** Trend = {word} ***")
google_urls, ddg_urls = [], []
Expand All @@ -91,7 +91,6 @@ def fake_traffic(country='US', language='en-US'):
for i, url in enumerate(article_urls, start=1):
recursive_browse(url)
print(f"{i}/{len(article_urls)} urls recursive browsing.")



if __name__ == '__main__':
fake_traffic(country='US', language='en-US')

0 comments on commit 1e6f220

Please sign in to comment.