Python Forum

Full Version: pytrends problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I also have found the easier one, but the pytrends package still can't work.

from pytrends.pyGTrends import pyGTrends
import time
from random import randint
def run_search(keyword):
google_username = '' #Enter google username
google_password = '' #Enter google password

#Connect to google
connector = pyGTrends(google_username, google_password)

#Request a report based on keyword
connector.request_report(keyword, geo = 'US', date = '03/2006 118m')
print(keyword)

#Wait a bit so Google doesn't block the script
time.sleep(randint(5,10))

#Save a csv
path = './output/'
connector.save_csv(path, keyword)

with open("fund name.txt", "r") as source:
lines = [line.rstrip('\n').replace('/', ' ').replace(',','') for line in source]
for name in lines:
run_search(name)
print("Finished!")
Pages: 1 2