tweepy

Tweepy StreamListener to CSV

主宰稳场 提交于 2019-12-04 17:55:50
I'm a newbie on python and I'm trying to develop an app that retrieves data from Twitter with Tweepy and the Streaming APIs and converts the data on a CSV file. The problem is that this code doesn't create an output CSV file, maybe because I should set the code to stop when it achieves for eg. 1000 tweets but I'm not able to set this stop point here's the code import sys import tweepy import csv #pass security information to variables consumer_key="" consumer_secret="" access_key = "" access_secret = "" #use variables to access twitter auth = tweepy.OAuthHandler(consumer_key, consumer_secret)

How to get all users in a list Twitter API?

*爱你&永不变心* 提交于 2019-12-04 15:27:27
Is there a way to access all members in a list? Currently, I can only see the first 20 members? Specifically, I'm using python and tweepy. In Tweepy, this can be facilitated by using the Cursor class Tweepy provides, which implements an appropriate iterator for the model returned to you depending on your desired method call. In your case, you want to initialize a Cursor with the list_members() method and parameters for the list owner and the list slug (see https://dev.twitter.com/docs/api/1/get/lists/members ). Example (modified from http://packages.python.org/tweepy/html/code_snippet.html

Python Tweepy: Twitter Api saying that /users/lookup does not exist

ぐ巨炮叔叔 提交于 2019-12-04 14:33:48
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

How to use the 'count' parameter in tweepy's streaming API?

泪湿孤枕 提交于 2019-12-04 14:10:19
I can use the streaming API just fine when I don't include the count parameter in filter() call, but when I try to specify how many tweets from my history I want to receive, my stream object returns None . import tweepy from tweepy.streaming import StreamListener, Stream class Listener (StreamListener): def on_status(self, status): print '-' * 20 print status.text return def get_tweets(request): # if request.is_ajax(): # All keys and secrets are declared here, but were removed for security reasons. auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY,

streaming api with tweepy only returns second last tweet and NOT the immediately last tweet

元气小坏坏 提交于 2019-12-04 13:45:35
I am new to not only python, but programming altogether so I'd appreciate your help very much! I am trying to filter detect all tweets from the twitter streaming API using Tweepy. I have filtered by user id and have confirmed that tweets are being collected in real-time. HOWEVER , it seems that only the second last tweet is being collected in real-time as opposed to the very latest tweet. Can you guys help? import tweepy import webbrowser import time import sys consumer_key = 'xyz' consumer_secret = 'zyx' ## Getting access key and secret auth = tweepy.OAuthHandler(consumer_key, consumer_secret

Retweeters of a Twitter status in Tweepy

拟墨画扇 提交于 2019-12-04 13:02:25
问题 This is kindof a followup question to this question. I want to get the ID of the users that have retweeted a particular tweet. I tried following the same technique but I'm getting an error. Here's the code: import tweepy auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) firstTweet = api.user_timeline("github")[0] print firstTweet.text print firstTweet.id results = api.retweeted_by(firstTweet.id) print results This

tweepy/ twitter api error type

南楼画角 提交于 2019-12-04 12:48:59
问题 I am using tweepy to make a twitter application. When users tweet/update profile, etc, they will get some errors. I want to classify error and give user more information. try: tweet/update profile/ follow.... except tweepy.TweepError, e: if tweepy.TweepError is "Account update failed: Description is too long (maximum is 160 characters)" Do something if tweepy.TweepError is "Failed to send request: Invalid request URL: http://api.twitter.com/1/account/update_profile.json?location=%E5%85%B5%E5

Using Tweepy to search for tweets with API 1.1

£可爱£侵袭症+ 提交于 2019-12-04 10:51:19
问题 I've been trying to get tweepy to search for a sring without success for the past 3 hours. I keep getting replied it should use api 1.1. I thought that was implemented... because I can post with tweepy. What am I doing wrong? #!/usr/bin/env python import tweepy consumer_key = '***' consumer_secret = '***' access_token = '***' access_token_secret = '***' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth)

How to create a pandas dataframe using Tweepy?

爷,独闯天下 提交于 2019-12-04 09:05:43
In Python 3 I made program to extract posts and likes in Twitter: import tweepy import pandas as pd consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) This function receives the didactic classification of profiles (only for database organization) and the name of the profile. It creates a list with dictionaries, which is then returned: def linhadotempo(posicao, valor): tela = api.user_timeline(valor) bolha = [] for status in

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

别来无恙 提交于 2019-12-04 06:43:13
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-16-2019 | lorem ipsum… | | user2 | 321 | 12151 | 2017 | 0 | Sep-12-2018 | lorem ipsum… | | user2 | 321