2017-05-15 4 views
0

私はエラーを取得するために、次のコードを実行しますpytrends_json.decoder.JSONDecodeError:期待値:行1列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:期待値:行1列1(CHAR 0)

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

JSONDecodeError:期待値:行1列1(CHAR 0)同様の問題を有する

誰? ありがとう!

答えて

0

pipのpytrendsが古くなっているようです。少なくとも、彼らはdifferent URL for trending searchesを使用

:UPDATE 1 gitの

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

からpytrendsを取るようにしてください。ピップ(pytrends/request.py)から 出典:masterブランチから

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" 

ソース:

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

ピップのバージョンは9.0.1で、pytrendsバージョンは、それらの4.1.1 両れています最新のバージョン... –

+0

@VickyChang私はちょうど私の答えを更新しました –

+0

あなたの助けをありがとう! –

関連する問題