tweepy

User ID to Username tweepy

血红的双手。 提交于 2019-12-18 14:46:14
问题 Can someone please tell me how to get one username from one id on tweepy? I have looked everywhere and can't find anything. 回答1: If you just have a user_id value you need to call the twitter API with the get_user(user_id) method. The returned User object will contain the username under screen_name. # steps not shown where you set up api u = api.get_user(783214) print u.screen_name If you already have the User object from another API call just look for the screen_name. 回答2: You can use this

User ID to Username tweepy

二次信任 提交于 2019-12-18 14:46:01
问题 Can someone please tell me how to get one username from one id on tweepy? I have looked everywhere and can't find anything. 回答1: If you just have a user_id value you need to call the twitter API with the get_user(user_id) method. The returned User object will contain the username under screen_name. # steps not shown where you set up api u = api.get_user(783214) print u.screen_name If you already have the User object from another API call just look for the screen_name. 回答2: You can use this

Tweepy - Exclude Retweets

限于喜欢 提交于 2019-12-17 18:24:31
问题 Ultimate goal is to use the tweepy api search to focus on topics (i.e docker) and to EXCLUDE retweets. I have looked at other threads that mention excluding retweets but they were completely applicable. I have tried to incorporate what I've learned into the code below but I believe the "if not" piece of code is in the wrong place. Any help is greatly appreciated. #!/usr/bin/python import tweepy import csv #Import csv import os # Consumer keys and access tokens, used for OAuth consumer_key =

Get data from Twitter using Tweepy and store in csv file

痞子三分冷 提交于 2019-12-17 17:59:41
问题 I'm new to Python, Twitter, and Tweepy. I managed to pull data from Twitter, but I now want to store it into a CSV file. My code is: #!/usr/bin/python import tweepy auth = tweepy.auth.OAuthHandler('XXXXXX', 'XXXXXXX' auth.set_access_token('XXX-XXX', 'XXX' api = tweepy.API(auth) for tweet in tweepy.Cursor(api.search, q="google", since="2014-02-14", until="2014-02-15", lang="en").items(): print tweet.created_at, tweet.text This prints data out on CLI, but I want it to output to a CSV file. I

urllib.request in Python 2.7

半腔热情 提交于 2019-12-17 15:44:17
问题 I can use urllib.request module with Python 3.1. But when I execute the same program using Python 2.7, an error comes along the lines of; AttributeError: 'module' object has no attribute 'request'. I believe this error is because theres no request module in urllib for Python 2.7. Because I need to use tweepy i'll have to stick with Python 2.7 since tweepy does not support Python 3. So how I can use urllib.request module in Python 2.7? 回答1: use urllib2.urlopen 回答2: It is also possible to use

Error using api.update_status method in tweepy using Oauth2

假如想象 提交于 2019-12-13 17:14:01
问题 Here is my code:- I have double checked all the auth parameters. import tweepy CONSUMER_KEY ='#Omitted - you should not publish your actual key' CONSUMER_SECRET ='#Omitted - you should not publish your actual secret' ACCESS_KEY='#Omitted - you should not publish your access key' ACCESS_SECRET = '#Omitted - you should not publish your access secret' auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) api.update

Using regular expression in Twitter API

谁都会走 提交于 2019-12-13 11:44:52
问题 I am using Tweepy Library in Python to search for tweets. I am wondering, if I can use regular expression to search Tweets. I am using the following code : query = 'ARNOLD or SYLVESTER' for tweet in tweepy.Cursor(api.search, query, count=100, result_type="recent", include_entities=True, lang="en").items(): For instance, can I search for all tweets which uses 'ARNOLD' or 'SYLVESTER' ( all capital/single word) an ignore all the other tweets. I am currently processing the tweets after obtaining

How to use API.statuses_lookup in Tweepy

半腔热情 提交于 2019-12-13 08:45:37
问题 I am looking an example how to use "API.statuses_lookup". 回答1: use tweets = self.api.statuses_lookup(tweetIDs) tweetIDs is a list of your tweet ids ,which u have from ur database or somewhere else in response you will get a status object now use for loop **for tweet in tweets: #tweet obtained print(str(tweet['id'])+str(tweet['text']))** u can provide maximum 100 tweets 来源: https://stackoverflow.com/questions/39828384/how-to-use-api-statuses-lookup-in-tweepy

Tweepy Cursor vs Iterative for low API calls

依然范特西╮ 提交于 2019-12-13 04:25:29
问题 I am writing a simple Tweepy application for fun, but am really limited to how many API calls I have (anywhere between 150 and 350). So to account for this I am looking for ways to cut calls. Tweepy has a cursor system built in. Eg: # Iterate through all of the authenticated user's friends for follower in tweepy.Cursor(api.followers).items(): follower.follow() For those who are familiar with this library. Would the above example be more or less efficient than simply... for follower in api

Tweepy Not filtering on Since

可紊 提交于 2019-12-13 03:50:58
问题 I have found many examples of the tweepy cursor where a parameter is "since = "YYYY-MM-DD"". However, in my code below, it is returning tweets much older than the date I specify. Why? since = "2017-9-20" tweepy.Cursor(api.search, q="nba -filter:retweets", since = since, rpp=100, result_type="recent", include_entities=True, lang="en", ).items(10) tweet.text An example of a tweet it returns is: created_at=datetime.datetime(2011, 9, 19, 18, 12, 50) id=376333795 回答1: I think you are looking at a