tweepy

Return the number of remaining hits tweepy

坚强是说给别人听的谎言 提交于 2019-12-24 21:35:25
问题 EDIT: I am trying the following code in order to read a list of ids and get their corresponant names. I am trying to use reamin_search_limits in order to avoid rate_limit errors. limits = api.rate_limit_status() remain_search_limits = limits['resources']['search']['/search/tweets']['remaining'] stream = open('myfile','w') ss = open('userNames', 'w') for ids in content: try: limits = api.rate_limit_status() remain_search_limits = limits['resources']['search']['/search/tweets']['remaining']

How to send an image in direct message?

我与影子孤独终老i 提交于 2019-12-24 17:57:00
问题 I'm trying to send an image in direct message using python + tweepy but no luck. It showed as a link in incoming messages. imgurl = 'https://t.co/***' api.send_direct_message(screen_name='username',text=' '+imgurl) Could you please advise? Official Twitter API doesn't shed a light for me as well. 回答1: At the moment, you are sending a link. Literally a status message where the text is a URL. Sadly, Twitter don't provide API access for uploading images via DM. If you are able to use Twitter's

How to send an image in direct message?

时光总嘲笑我的痴心妄想 提交于 2019-12-24 17:56:03
问题 I'm trying to send an image in direct message using python + tweepy but no luck. It showed as a link in incoming messages. imgurl = 'https://t.co/***' api.send_direct_message(screen_name='username',text=' '+imgurl) Could you please advise? Official Twitter API doesn't shed a light for me as well. 回答1: At the moment, you are sending a link. Literally a status message where the text is a URL. Sadly, Twitter don't provide API access for uploading images via DM. If you are able to use Twitter's

Tweepy - is it possible to stream exact phrases?

£可爱£侵袭症+ 提交于 2019-12-24 17:16:22
问题 TheStreamer.filter(languages=["en"], track=['Bruno Mars is lovely']) Is there a way to get this to track an exact phrase, rather than relevant phrases? For instance, 'Bruno Mars really is a lovely man' would probably be a result, which I don't want. 回答1: As per the documentation for track Exact matching of phrases (equivalent to quoted phrases in most search engines) is not supported. So the simple answer is no, you cannot prevent matching tweets in which all words are present in any order

TweePy - how to hide API key

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 15:03:07
问题 I am building simple app which is using Twitter API. What I have to do to hide my Twitter app keys? For example, if I will put my program to the internet and somebody who look up to the code will know my consumer key, access token etc. And if I not include this information into my program, that it won't be work! 回答1: I'm assuming by putting on the internet you mean publishing your code on github or such. In that case you should always separate code and configuration. Put your API keys in an

Twitter Streaming: Get trends on Twitter on the basis of countries

匆匆过客 提交于 2019-12-24 13:10:35
问题 I am using tweepy to get twitter tweets. I want to get the current trends based on the country of my choice. My code is as follows: import tweepy file = open("data.txt", 'r') authentication = tweepy.OAuthHandler('consumer_key', 'consumer_secret') authentication.set_access_token('access_token', 'access_secret') api = tweepy.API(authentication) trends = api.trends_available() for trend in trends: print trend The code above gives me a list of countries. I want to use the list to check the

How to get popular tweets from a user with tweepy?

隐身守侯 提交于 2019-12-24 11:27:12
问题 I am trying to get popular tweets from a specific user with tweepy. I need something like result_type = 'popular' from the twitter API (https://dev.twitter.com/rest/reference/get/search/tweets). How can I do that? 回答1: With Python, try this to get 5 popular tweets with tag #yoursearch : for tweet in tweepy.Cursor(api.search, q='#yoursearch',result_type='popular').items(5): print(tweet) 来源: https://stackoverflow.com/questions/31903741/how-to-get-popular-tweets-from-a-user-with-tweepy

Python - writing a variable to a text file

夙愿已清 提交于 2019-12-24 10:45:37
问题 So this is my very first attempt at Python and programming the Raspberry Pi. My small project is to light an LED when I get a mention on Twitter. All very simple and the code shown below works well. My question relates to storing the previous mentions in a text file instead of a variable. Essentially the code checks the printed_ids variable for the list of tweet.ids that have already been seen so as to prevent the LED's from just continually flashing every time the program is re-run. My plan

Twitter Bot with Tweepy - Python

て烟熏妆下的殇ゞ 提交于 2019-12-24 08:47:09
问题 I have been working on a Twitter Bot which replies to people with "im" in their message with "Hi ___, I'm Dad!". I used to have it working before, but then my computer died and lost all of it's files. I wrote the original bot a couple years ago, and I haven't looked at Tweepy in a while. I was pretty sure I had it 100% figured out - and no errors popped up, but the bot isn't working and I don't know why. I can log in just fine, but something is wrong with the actual replying part. Can someone

Tweepy Look up ID with username

时光怂恿深爱的人放手 提交于 2019-12-24 07:36:05
问题 I am trying to get a list of IDs from a list of usernames I have. Is there any method that tweepy provides that lets me do lookup user IDs using their username? 回答1: Twitter API has the resource https://dev.twitter.com/rest/reference/get/users/lookup for such requirements. It can return user objects for at most 100 users at a time. You can use this in Tweepy like: user_objects = api.lookup_users(screen_names=list_of_at_most_100_screen_names) user_ids = [user.id_str for user in user_objects]