0

Using Python, I am attempting to scrape data from Google Trends for "topics" (as opposed to "search terms").

I am currently using the pytrends module, but it appears it's not (currently) possible to scrape topics rather than search terms, unless you know the topic_id.

E.g. if you wanted to scrape the data for the topic_name "Holiday", you could search using the topic_id /m/03gkl, but only if you knew that that was the topic_id.

I have a list of topic names. I would like a corresponding list of topic ids. How can I achieve this?

OD1995
  • 1,647
  • 4
  • 22
  • 52

1 Answers1

0

It looks like I didn't read the pytrends documentation properly and it is possible to get the topic id:

from pytrends.request import TrendReq
pytrends = TrendReq(hl='en-US', tz=360)
suggs = pytrends.suggestions("iron")
print(suggs)

[{'mid': '/m/025rw19', 'title': 'Iron', 'type': 'Chemical element'},
 {'mid': '/m/04jphh9', 'title': 'Clothes iron', 'type': 'Topic'},
 {'mid': '/m/0b6l369', 'title': 'Loha', 'type': '1987 film'},
 {'mid': '/m/03cld36', 'title': 'Iron', 'type': 'Golf'},
 {'mid': '/m/0281ql7', 'title': 'Ferric', 'type': 'III'}]

From the above, it is easy to extract the topic id.

OD1995
  • 1,647
  • 4
  • 22
  • 52