![](/img/trans.png)
[英]How to set the sub category of search term Google Trends - Pytrends
[英]Google Trends Category Search
我正在嘗試根據以下鏈接中的列表使用 Python按類別和/或子類別提取/下載 Google 趨勢系列數據: https://github.com/pat310/google-trends-api/wiki/Google-Trends -類別
此類別列表包含在 Google 趨勢的(非官方)API 中使用的代碼,名為pytrends 。 但是,我不能只按類別搜索,因為它需要提供關鍵字/搜索詞。 在下面的例子中,我們有類別 47(汽車和車輛)和關鍵字 ['BMW', 'Peugeot']。
import pytrends
from pytrends.request import TrendReq
pytrend = TrendReq()
pytrend = TrendReq(hl='en-US', tz=360)
keywords = ['BMW', 'Peugeot']
pytrend.build_payload(
kw_list=keywords,
cat=47,
timeframe='today 3-m',
geo='FR',
gprop='')
data = pytrend.interest_over_time()
data= data.drop(labels=['isPartial'],axis='columns')
image = data.plot(title = 'BMW V.S. Peugeot in last 3 months on Google Trends ')
fig = image.get_figure()
我發現這是一個可能的解決方案,但我沒有嘗試過,因為它在 R: https://github.com/PMassicotte/gtrendsR/issues/89
我不知道是否有 API 可以按類別提取系列並忽略關鍵字/搜索詞。 讓我知道它是否存在。 我相信一個選擇是直接從谷歌趨勢網站下載並填寫類別字段,就像這個例子一樣,我們可以看到類別“汽車和車輛”的系列: https://trends.google.com/trends/探索?cat=47&date=all&geo=SG
您可以通過 kw_list 數組中的空字符串類別進行搜索:
keywords = ['']
pytrend.build_payload(kw_list=[''], cat=47,
timeframe='today 3-m', geo='FR', gprop='')
data = pytrend.interest_over_time()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.