zazencodes / twitter_search

High level script for finding tweets using Python 3 and Tweepy
https://galeascience.wordpress.com/2016/03/18/collecting-twitter-data-with-python/
168 stars 74 forks source link

api.search() How to use filters like images and links. #3

Open zoid-anurag opened 7 years ago

zoid-anurag commented 7 years ago

I want to search only those tweets that contain an image. The twitter documentation mentions use of operators as filters Link: https://dev.twitter.com/rest/public/search

If I use twitter search through browser the filter operators works. so if i search for "puppy filter: images" I get results with tweets containing text puppy and every tweet has an image. The search url for API HTTP request is Link: https://twitter.com/search?src=typd&q=puppy%20filter%3Aimages

Please suggest any solution. I want to search for relevant tweets because of the rate limit rather than downloading a whole bunch and then filtering json file.

Kanishk-Anand commented 7 years ago

I am trying to run the script but it throws the following Search phrase = #Messi Traceback (most recent call last): File "search.py", line 189, in main() File "search.py", line 157, in main since_id = get_tweet_id(api, days_ago=(max_days_old-1)) File "search.py", line 80, in get_tweet_id tweet = api.search(q=query, count=10, until=tweet_date) File "/usr/local/lib/python3.5/dist-packages/tweepy/binder.py", line 245, in _call return method.execute() File "/usr/local/lib/python3.5/dist-packages/tweepy/binder.py", line 229, in execute raise TweepError(error_msg, resp, api_code=api_error_code) tweepy.error.TweepError: [{'message': 'Bad Authentication data.', 'code': 215}]

Any help will be appreciated.