2015-04-17 29 views
0

example picture(Python/Tweepy) - 我可以查詢包含特定URL的twitter個人資料嗎?

凡說google.com ...

我想創建一個腳本,它的URL「google.com」,然後返回個人資料頁或信息。

到目前爲止,我所做的完全是我想要的,除非您必須爲其指定屏幕名稱,然後使用屏幕名稱來獲取配置文件。

import tweepy 
from pprint import pprint 


consumer_key = 'something' 
consumer_secret = 'something' 
access_token = 'something' 
access_token_secret = 'something' 

auth = tweepy.OAuthHandler(consumer_key, consumer_secret) 
auth.set_access_token(access_token, access_token_secret) 

api = tweepy.API(auth) 


user =api.get_user('google') 

print user 

如果Tweepy不提供對此的支持,我願意接受所有建議。謝謝。

回答

2
    您使用了錯誤的終點作業
  1. ,你應該使用這tweepy對應api.search_users this 終點(Q)如何構建參數q
  2. 檢查here
  3. 如果它的作品,如果你通過網址作爲參數取決於特定的Twitter用戶的主頁和其他因素的內容。也許你會有更好的機會,如果你拆開網址,並使用該域名,即:api.search_users(「谷歌COM」)
+0

感謝的形象描述,該查詢工作。結果的格式是什麼? JSON? – user3063864

+0

Twitter API終結點返回json,有時驅動程序將其轉換爲其他內容 – nickmilon

1

#類用戶包含用戶 #的所有的輪廓特徵,這裏的userid是用戶的網名

class User(object): 

     def __init__(self, userid): 
      self.userid = userid 
      self.user = api.get_user(self.userid) 

#獲取用戶

 def get_profile(self): 
      return self.user.description 
相關問題