I am getting a "ResponseError: The request failed: Google returned a response with code 400." whilst using the pytrends package. Here is my script:
import pytrends
from pytrends.request import TrendReq
import pandas as pd
import time
import datetime
from datetime import datetime, date, time
import pandas as pd
import csv, itertools
from collections import defaultdict
columns = defaultdict(list)
limit = 10
with open('file.csv') as f:
reader = csv.DictReader(f)
for idx, row in enumerate(reader, 1):
for (k,v) in row.items():
columns[k].append(v)
if idx == limit:
break
kw = (columns['Keyword'])
pytrend = TrendReq()
pytrend.build_payload(kw_list=kw, timeframe='today 12-m', geo = 'GB')
interest_over_time_df = pytrend.interest_over_time()
print(interest_over_time_df)
My current script reads a CSV and converts a column into a list, which is then read to get the keyword data. Is there an issue with my script, or am I just being timed out/blocked from Google of making requests?
Here is an example of the output of the "kw" variable I am reading.
['travel agents',
'turkey holidays',
'travel agents near me',
'holiday companies',
'smartline ficus',
'bellevue bonita',
'benidorm',
'travel agent',
'holidays to turkey',
'18-30 holidays']
Thanks.