使用Twitter的API和Python来obatain retweeter的id [英] Using the twitter API and Python to obatain retweeter's id

查看:926
本文介绍了使用Twitter的API和Python来obatain retweeter的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已经困扰了一段时间了,并且我已经试过真的很难修复,但没有发现任何解决方案的问题。
所以我在做实习做复杂网络研究的,没有什么商业为主,它主要是物理和网络理论的研究,他们正在做的事情。
所以,我在做什么是写剧本为他们获得来自Twitter和tumblr(如好友列表和锐推)数据,然后再绘制图形用户到用户的关系。

不管怎么说,直接去了我的问题,我已经写我的剧本pretty多,主要使用Twitter的Python包装。然而,没有任何包装为Python已经使用GET状态/锐推/任何方式:ID返回100第一retweeter的标识。我已经通过了所有的蟒蛇不同的Twitter图书馆看了看,什么也找不到。
我发现翠儿的MATLAB,但我使用Ubuntu,这并不容易获得。

我的问题是,我怎么能实现此API自己,没有包装?有没有包装,即使在你们会知道,让我这样做另一种语言?我不会介意在一个文件中的信息转推,然后用我的python脚本走了过来,并得到我需要的信息。

非常感谢你!
这是资源我想使用:
https://dev.twitter.com/docs/api/ 1.1 /获取/状态/锐推/%3Aid

编辑:
因此,与tweepy这就是我想要做的。

  AUTH = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN,ACCESS_TOKEN_SECRET)鸣叫= auth.retweets(TWEET_ID)打印json.dumps(鸣叫,缩进= 1)


解决方案

看起来像 tweepy 应为你工作。请参见文档和的来源

例如:

 进口tweepyAUTH = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
auth.set_access_token(键,密码)API = tweepy.API(AUTH)public_tweets = api.search(计算器)
在public_tweets鸣叫:
    打印api.retweets(tweet.id)

希望有所帮助。

I have an issue that has been bothering for a while now, and which I have tried really hard to fix but have found no solution. So I'm doing an internship doing research on complex networks, nothing business-oriented, it's mostly physics and network theory research that they are doing. So what I'm doing is writing scripts for them to obtain data from twitter and tumblr (such as friend lists, and retweets) and then then graphing the user-to-user relations.

Anyways, going straight to my problem, I have already written my script pretty much, mainly using the twitter-python wrapper. However, none of the wrappers for python has any way of using the GET statuses/retweets/:id which returns the 100 first retweeter's ids. I've looked through all different twitter libraries for python and could not find anything. I found tweety for MATLAB but I'm using Ubuntu and it hasn't been easy to obtain.

So my question is, how can I implement this API myself, without a wrapper? is there any wrapper, even in another language that you guys would know allows me to do this? I wouldn't mind getting the retweet information in a file and then using my python script to go over it and get the information I need.

Thank you very much! This is the resource I wanna use: https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid

EDIT: So with tweepy this is what I'm trying to do

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

tweet = auth.retweets(TWEET_ID)

print json.dumps(tweet, indent=1)

解决方案

Looks like tweepy should work for you. See docs and source.

Example:

import tweepy

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(key, secret)

api = tweepy.API(auth)

public_tweets = api.search("stackoverflow")
for tweet in public_tweets:
    print api.retweets(tweet.id)

Hope that helps.

这篇关于使用Twitter的API和Python来obatain retweeter的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆