Python Tweepy: Twitter Api saying that /users/look

2019-05-26 16:46发布

I'm making a research application which studies interactions between twitter users with high authority. Part of it is extracting information about the users. I built an application using Tweepy for Python and I've been extracting user information for that past 2 days without any porblems. All of a sudden for a request like:

https://api.twitter.com/1.1/users/lookup.json?user_id=14063469%2C175965206%2C116959518%2C19814396%2C59871521%2C15879224%2C53116337%2C60620244%2C22667202%2C56455965%2C40655442%2C6532392%2C24316973%2C21831390%2C19028429%2C28954030%2C31137878%2C16907284%2C16583745%2C9940452%2C19589935%2C935591%2C14602269%2C20546508%2C19773867%2C16082041%2C18320759%2C14084545%2C8731882%2C14795384%2C15664019%2C7417012%2C14634678%2C9269402%2C2348251%2C14573469%2C14441717%2C14451994%2C14412513%2C4084791%2C11922062%2C7080762%2C11916972%2C14449235%2C252192024%2C9067522%2C4084791%2C252192024%2C258597311%2C252192024%2C31920384%2C206028892%2C18495777%2C22663733%2C27221188%2C289510168%2C446444558%2C14540077%2C25195065%2C1705881%2C4084791%2C8937822%2C252192024%2C252192024%2C252192024%2C112627470%2C252192024%2C41906537%2C14822470%2C230684649%2C35758042%2C268838947%2C252192024%2C252192024%2C43303458%2C164029686%2C116950595%2C109449411%2C226911474%2C73931555%2C170619878%2C153925191%2C113826502%2C60094002%2C51161658%2C68858451%2C23453566%2C120360129%2C98659794%2C42160791%2C125832535%2C119379318%2C118153517%2C18596842%2C65443306%2C74994114%2C49875356%2C50401629%2C115960551%2C101979193

I get back

[{u'message': u'Sorry, that page does not exist', u'code': 34}].

Does anyone know what might be wrong?

3条回答
Anthone
2楼-- · 2019-05-26 16:48

Here's how to use the Tweepy lookup_users method:

>>> api = tweepy.API(auth)
>>> test = api.lookup_users(user_ids=['1123728482,5539932'])
>>> test
[<tweepy.models.User object at 0x103995090>, <tweepy.models.User object at 0x1039950d0>]
查看更多
狗以群分
3楼-- · 2019-05-26 16:51

Your code is probably working, getting a 34 error is common when people close or change accounts and you need to wrap your code in try/except to deal with that. Other than that the code from The RG should do the trick.

查看更多
唯我独甜
4楼-- · 2019-05-26 16:54
users_list = api.lookup_users(user_ids=id_list)
for user in users_list:
   print user.screen_name

You can try this and the id_list is a list of user IDs. You can also refer to tweepy how to get a username from id

查看更多
登录 后发表回答