justinzm/gopup

请问谷歌指数能否选择地区?

Preshire opened this issue · 1 comments

目前是否是显示**地区的热度,请问能否选择国家呢?

以及如果是日为单位,请问该怎么设定呢?谢谢!

+1,

这个我在源码中看到了有个“geo”的参数,是指定国别的,可否直接开放为可选参数,允许指定;

原代码:

def google_index(keyword="python", start_date="2019-12-01", end_date="2019-12-04"):
    """
    返回指定区间的谷歌指数
    :param keyword:
    :param start_date:  2019-12-10T10
    :param end_date:    2019-12-10T23
    :return:
    """
    try:
        pytrends = TrendReq(hl="en-US", tz=360)
        kw_list = [keyword]
        pytrends.build_payload(
            kw_list, cat=0, timeframe=start_date + " " + end_date, geo="", gprop=""
        )
        search_df = pytrends.interest_over_time()
        search_df['value'] = search_df[keyword]
        search_df['date'] = search_df.index
        res_df = search_df.drop(['isPartial', keyword], axis=1)
        return res_df
    except:
        return None