[{''code':34,'message':'对不起,该页面不存在。'}]

时间:2018-12-05 11:07:59

标签: python twitter tweepy

    import tweepy
    import json

    CONSUMER_KEY = ''
    CONSUMER_SECRET = ''
    OAUTH_TOKEN = ''
    OAUTH_TOKEN_SECRET = ''

    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

    twitter_api = tweepy.API(auth)
    country_id = {'World': 1,'UK': 23424975}
    for country in country_id.keys(): 
        print (country)

    country = input("Enter the name of the place.\n")

     if country in country_id.keys():

          print ('The top 10 trending topics in ' +country+' are:')
          print ('------------------------------\n')

    PLACE_WOE_ID = country_id[country]

    place_trends = twitter_api.trends_place(_id=PLACE_WOE_ID)
    count = 1
    for trend in place_trends[0]['trends']:
        print (str(count) + ') ' + trend['name'])
        count+=1
    print ('\n Thank You for using the service.')

else:

    print (' not available.')

我收到以下错误。我是Twitter API的新手,真的很喜欢例外...这给了我一个找不到代码的34页。我无法理解。我正在尝试显示特定国家的趋势。

Traceback (most recent call last):
  File "C:/Users/user/Documents/twipgm.py", line 44, in <module>
    place_trends = twitter_api.trends_place(_id=PLACE_WOE_ID)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tweepy\binder.py", line 250, in _call
    return method.execute()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tweepy\binder.py", line 234, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{'code': 34, 'message': 'Sorry, that page does not exist.'}]

0 个答案:

没有答案
相关问题