GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.12k stars 798 forks source link

Impossible to get data for worldwide after any country has been set #600

Open AlexYurkin opened 8 months ago

AlexYurkin commented 8 months ago

It is because of the code below, where self.geo = geo or self.geo. If self.geo was set to any country in previous build, then if next build will have geo as empty string (for worldwide), it won't be set to empty string, instead it will be the country from previous build.

def build_payload(self, kw_list, cat=0, timeframe='today 5-y', geo='',
                      gprop=''):
        """Create the payload for related queries, interest over time and interest by region"""
        if gprop not in ['', 'images', 'news', 'youtube', 'froogle']:
            raise ValueError('gprop must be empty (to indicate web), images, news, youtube, or froogle')
        self.kw_list = kw_list
        self.geo = geo or self.geo