GeneralMills/pytrends

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

AlexYurkin opened this issue · 0 comments

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