tweepy

How to extract data from a Tweepy object into a pandas dataframe?

試著忘記壹切 提交于 2019-12-21 12:22:43
问题 I am attempting to create a Pandas dataframe that looks like: | user_name | followers | following | retweets | likes | tweet date | tweet | |:---------:|:---------:|:---------:|:--------:|:-----:|:-----------:|:------------:| | user1 | 50 | 100 | 25 | 10 | Oct-1-2019 | lorem ipsum… | | user1 | 50 | 100 | 25 | 10 | Oct-6-2019 | lorem ipsum… | | user1 | 50 | 100 | 25 | 10 | Oct-19-2019 | lorem ipsum… | | user1 | 50 | 100 | 25 | 10 | Oct-4-2019 | lorem ipsum… | | user1 | 50 | 100 | 25 | 10 | Oct

Original tweet or retweeted?

佐手、 提交于 2019-12-21 12:22:25
问题 I am using Tweepy with python and trying to get the original tweets authored by set of users (i.e., I want to exclude any tweet in their timeline that is actually a retweet). How can I do this with Tweepy? I tried something like this and I do not know if it works: tweets = api.user_timeline(id=user['id'], count=30) for tweet in tweets: if not tweet.retweeted: analyze_tweet(tweet) Does the api.user_timeline() return only original tweets? Or retweets of this user as well? 回答1: Tweepy by default

Convert tweepy JSON object to dict

孤人 提交于 2019-12-21 05:33:13
问题 I'd like to convert the result of a Tweepy api.trends_location(woeid) call to a dict (or a dict of dicts), so I can work with the values (really, I want to end up with a dict of the 'name' values). The Tweepy documentation says that the result is 'a JSON object' (see here), but when I retrieve it, type(retrieved) evaluates to list . Sure enough, retrieved has a len of 1, and retrieved[0] gives me a single item: [{'trends': [{'url': 'http://search.twitter.com/search?q=%23questionsidontlike',

Traceback when updating status on twitter via Tweepy

 ̄綄美尐妖づ 提交于 2019-12-21 04:09:12
问题 I've been trying to post the readings from my Rpi on Twitter using tweepy , but first I wanted to check if tweepy was working properly, but it's not. I installed the packages properly, but when I'm trying to run a simple code to post something, I got an error (Yes, I already created an app and have the 4 credentials). The code I'm trying to run: import tweepy consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' auth = tweepy.OAuthHandler(consumer_key, consumer

how to take all tweets in a hashtag with tweepy?

本小妞迷上赌 提交于 2019-12-20 15:33:29
问题 I'm trying to take every open tweets in a hashtag but my code does not go further than 299 tweets. I also trying to take tweets from a specific time line like tweets only in May 2015 and July 2016. Are there any way to do it in the main process or should I write a little code for it? Here is my code: # if this is the first time, creates a new array which # will store max id of the tweets for each keyword if not os.path.isfile("max_ids.npy"): max_ids = np.empty(len(keywords)) # every value is

Using tweepy to access Twitter's Streaming API

荒凉一梦 提交于 2019-12-20 09:45:44
问题 I'm currently having trouble getting example code for using tweepy to access Twitter's Streaming API to run correctly (err...or at least how I expect it to run). I'm using a recent clone of tweepy from GitHub (labeled version 1.9) and Python 2.7.1. I've tried example code from three sources, in each case using "twitter" as a test term for tracking: O'Rilley Answers code: How to Capture Tweets in Real-time with Twitter's Streaming API Andrew Robinson's blog: Using Tweepy to access the Twitter

Tracking keywords in a live stream of tweets

余生长醉 提交于 2019-12-20 06:31:06
问题 I installed and tried out tweepy, I am using the following function right now: from API Reference API.public_timeline() Returns the 20 most recent statuses from non-protected users who have set a custom user icon. The public timeline is cached for 60 seconds so requesting it more often than that is a waste of resources. However, I want to do extract all tweets that match a certain regular expression from the complete live stream. I could put public_timeline() inside a while True loop but that

tweepy error python 2.7

柔情痞子 提交于 2019-12-20 02:55:02
问题 I keep getting this error: tweepy.error.TweepError: [{u'message': u'Status is a duplicate.', u'code': 187 I have no clue why I am getting this error I have tried everything! My main code is: import socket from urllib2 import urlopen, URLError, HTTPError socket.setdefaulttimeout( 23 ) # timeout in seconds url = 'http://google.co.uk' try : response = urlopen( url ) except HTTPError, e: tweet_text = "Raspberry Pi Server is DOWN!" textfile = open('/root/Documents/server_check.txt','w') textfile

Does Tweepy support running multiple Streams to collect data?

只谈情不闲聊 提交于 2019-12-20 02:47:12
问题 For example, I'd like to collect data related to three keywords: keyword1 keyword2 keyword3 I understand that I could collect them all at one time using: set track=[keyword1,keyword2,keyword3] . Is it possible to run three different Python processes to collect data for those keywords separately? 回答1: Unfortunately, no. Assuming you're using Tweepy's Stream class (which uses the Twitter Streaming API) you can not make multiple connections with a single account. You should also watch out if you

Getting whole user timeline of a Twitter user

不打扰是莪最后的温柔 提交于 2019-12-18 23:37:15
问题 I want to get the all of a user tweets from one Twitter user and so far this is what I came up with: import twitter import json import sys import tweepy from tweepy.auth import OAuthHandler CONSUMER_KEY = '' CONSUMER_SECRET= '' OAUTH_TOKEN='' OAUTH_TOKEN_SECRET = '' auth = twitter.OAuth(OAUTH_TOKEN,OAUTH_TOKEN_SECRET,CONSUMER_KEY,CONSUMER_SECRET) twitter_api =twitter.Twitter(auth=auth) print twitter_api statuses = twitter_api.statuses.user_timeline(screen_name='@realDonaldTrump') print