GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.28k stars 821 forks source link

Trending_searches() parameter pn keyword not found #207

Closed jgcbrouns closed 5 years ago

jgcbrouns commented 6 years ago

Dear all,

Upon invoking the trending_searches() method like so: pytrends.trending_searches(pn='p4') # in Japanese

I obtain the following error:

   test = pytrends.trending_searches(pn='p4') # in Japanese
   TypeError: trending_searches() got an unexpected keyword argument 'pn'

It seems like the last update did not follow through? Can anyone help me with this problem?

jgcbrouns commented 6 years ago

I installed via PIP. After researching the install directory I found that the method still has the old implementation

def trending_searches(self):
        """Request data from Google's Trending Searches section and return a dataframe"""

        # make the request
        forms = {'ajax': 1, 'pn': 'p1', 'htd': '', 'htv': 'l'}
        req_json = self._get_data(
            url=TrendReq.TRENDING_SEARCHES_URL,
            method=TrendReq.POST_METHOD,
            data=forms,
        )['trendsByDateList']
        result_df = pd.DataFrame()

        # parse the returned json
        sub_df = pd.DataFrame()
        for trenddate in req_json:
            sub_df['date'] = trenddate['date']
            for trend in trenddate['trendsList']:
                sub_df = sub_df.append(trend, ignore_index=True)
        result_df = pd.concat([result_df, sub_df])
        return result_df
cegprakash commented 6 years ago

👍 I have the same problem

datainvestor commented 6 years ago

So what is the status of this? I still got same error, when tried changing to different country.