2017-05-15 4 views
0

I den folgenden Code einen Fehler zu erhalten:pytrends_json.decoder.JSONDecodeError: Erwartung Wert: Zeile 1 Spalte 1 (char 0)

from pytrends.request import TrendReq 
google_username = '' 
google_password = '' 
pytrend = TrendReq(google_username, google_password, custom_useragent='My Pytrends Script') 
pytrend.build_payload(kw_list=['apple', 'sony'], timeframe = 'now 7-d') 

pytrend.trending_searches() 

JSONDecodeError: Erwartung Wert: Zeile 1 Spalte 1 (char 0)

pytrend.top_charts(date='201611', cid='apple', geo='US', cat='') 

JSONDecodeError: Erwartung Wert: Zeile 1, Spalte 1 (char 0)

Wer ähnliche Probleme haben? Vielen Dank!

Antwort

0

Sieht aus wie Pytrends in Pip ist veraltet. Versuchen Sie, nehmen pytrends von git

pip install git+https://github.com/GeneralMills/[email protected] --upgrade 

UPDATE 1:

Mindestens sie verwenden different URL for trending searches. Quelle von Pip (pytrends/request.py):

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

    # make the request 
    req_url = "https://www.google.com/trends/hottrends/hotItems" 

Quelle von Master-Zweig:

TRENDING_SEARCHES_URL = 'https://trends.google.com/trends/hottrends/hotItems' 

# some code 

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() 
+0

Die Pip-Version ist 9.0.1 und die pytrends Version 4.1.1 von ihnen Beide sind neueste Version ... –

+0

@VickyChang Ich habe gerade meine Antwort aktualisiert –

+0

Danke für Ihre Hilfe! –

Verwandte Themen