GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.21k stars 813 forks source link

UK City level data #497

Open kwjackson1988 opened 2 years ago

kwjackson1988 commented 2 years ago

When I use Google Trends webste itself, I am able to see trends down to a City level in the UK i.e. London, Manchester or wherever searches took place, take for example: https://trends.google.co.uk/trends/explore?date=now%201-H&geo=GB&q=Cars and make sure interest by sub-region has the dropdown of City selected, you wil see about 200 cities where this has been searched.

If I run the following code in Python:


import pytrends import pandas as pd from pytrends.request import TrendReq pytrends = TrendReq(hl='en-GB', tz=360, geo='gb') kw_list = ["Cars"] pytrends.build_payload(kw_list, cat=0, timeframe='now 1-H', geo='GB', gprop='')

data = pytrends.interest_by_region(resolution='COUNTRY', inc_low_vol=True, inc_geo_code=False)

data = pytrends.interest_by_region(resolution='DMA', inc_low_vol=True, inc_geo_code=False)

data = pytrends.interest_by_region(resolution='City', inc_low_vol=True, inc_geo_code=False)

data = pytrends.interest_by_region(resolution='REGION', inc_low_vol=True, inc_geo_code=False)

data = pytrends.interest_over_time()

df = pd.DataFrame(data) Final = df.reset_index()

Final = Final.drop(columns="isPartial")

Final


No matter which of the #Data lines i run, it comes back with the same result which is the split between England, Wales, Scotland & Ireland.

How can we get this api to drill down to the lower levels?

I have inc_low_vol=True, I thought the resolution='City' would be the answer but it's not.

I have looked at the code and can slightly understand it but I don't have any expertise to suggest any changes.

data = pytrends.interest_over_time() works as expected but this will just be for UK as a whole where I would love to get the data for the particular area for what has happened in the last hour or even 4 hours.

kwjackson1988 commented 2 years ago

Heyyy, anyone got any ideas on this?

JettScythe commented 2 years ago

There's a bug in the source code & city resolution is not working for any city outside of the US afaik. I've been using https://github.com/shevajia/PytrendsAddon & it has been working for me until #509 gets merged