Skip to content

amacinho/Twitter-API-Python-Tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction:

This project contains Python scripts that can be executed from the command line to get profiles, statuses, friends, and followers of Twitter users. There is a certain level of robustness. The scripts expect their input from the standard input and output the their results in JSON to standard output.

Dependencies:

tweepy (https://github.com/tweepy/tweepy) and for Python < 2.6 simplejson (http://pypi.python.org/pypi/simplejson/).

This file is part of Twitter API Python Tools (https://github.com/amacinho/Twitter-API-Python-Tools)
Twitter API Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Twitter API Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 

You should have received a copy of the GNU General Public License along Twitter API Tools. If not, see <http://www.gnu.org/licenses/>.

Notes:

--Format of auth.txt:
oauth.accessToken=************************************
oauth.accessTokenSecret=************************************
oauth.consumerKey=************************************
oauth.consumerSecret=************************************

Put twitter_common.py somewhere in PYTHONPATH. Fill in auth.txt as described above. Each line in the standard input should contain a user id or a screen name.

--Get statuses of a user:

echo "30186818" | python2.6 get_statuses_by_id.py 2>/dev/null | head -2
{"favorited": "False", "contributors": "None", "truncated": "False", "text": "@LeoWid you may find http://t.co/u5Bhjubn interesting. It shows the gender and time of the day differences in Twitter messages.", "user": "{'follow_request_sent': False, 'profile_use_background_image': False, 'contributors_enabled': False, 'id': 30186818, 'verified': False, 'profile_image_url_https': u'https://si0.twimg.com/profile_images/1348692482/cappello__normal.jpg', 'profile_sidebar_fill_color': u'DDEEF6', 'is_translator': False, 'profile_text_color': u'333333', 'followers_count': 86, 'profile_sidebar_border_color': u'2b2b2b', 'location': u'Cambridge, MA', 'default_profile_image': False, 'listed_count': 3, 'utc_offset': -14400, 'statuses_count': 87, 'description': u'Complex systems researcher with an interest in text mining and using social media to extract daily routines of people: http://www.tweetolife.com', 'friends_count': 69, 'profile_link_color': u'0084B4', 'profile_image_url': u'http://a0.twimg.com/profile_images/1348692482/cappello__normal.jpg', 'notifications': False, 'show_all_inline_media': False, 'geo_enabled': False, 'profile_background_color': u'000000', 'id_str': u'30186818', 'profile_background_image_url': u'http://a0.twimg.com/images/themes/theme1/bg.png', 'screen_name': u'amacinho', 'lang': u'en', 'profile_background_tile': True, 'favourites_count': 0, 'name': u'Ama\\xe7 Herda\\u011fdelen', 'url': u'http://www.herdagdelen.com', 'created_at': datetime.datetime(2009, 4, 10, 8, 40, 43), 'profile_background_image_url_https': u'https://si0.twimg.com/images/themes/theme1/bg.png', 'time_zone': u'Atlantic Time (Canada)', 'protected': False, 'default_profile': False, 'following': False}", "retweeted": "False", "in_reply_to_status_id_str": "None", "coordinates": "None", "source_url": "None", "source": "web", "in_reply_to_status_id": "None", "in_reply_to_screen_name": "LeoWid", "in_reply_to_user_id": "110821538", "in_reply_to_user_id_str": "110821538", "place": "None", "created_at": "2012-01-11 17:29:48", "retweet_count": "0", "geo": "None", "id": "157152238874263552", "possibly_sensitive": "False", "id_str": "157152238874263552"}
{"favorited": "False", "contributors": "None", "truncated": "False", "text": "How many calories does an average American burn daily, via exercise? Answer: http://t.co/vJSUYxgE on @Quora", "user": "{'follow_request_sent': False, 'profile_use_background_image': False, 'contributors_enabled': False, 'id': 30186818, 'verified': False, 'profile_image_url_https': u'https://si0.twimg.com/profile_images/1348692482/cappello__normal.jpg', 'profile_sidebar_fill_color': u'DDEEF6', 'is_translator': False, 'profile_text_color': u'333333', 'followers_count': 86, 'profile_sidebar_border_color': u'2b2b2b', 'location': u'Cambridge, MA', 'default_profile_image': False, 'listed_count': 3, 'utc_offset': -14400, 'statuses_count': 87, 'description': u'Complex systems researcher with an interest in text mining and using social media to extract daily routines of people: http://www.tweetolife.com', 'friends_count': 69, 'profile_link_color': u'0084B4', 'profile_image_url': u'http://a0.twimg.com/profile_images/1348692482/cappello__normal.jpg', 'notifications': False, 'show_all_inline_media': False, 'geo_enabled': False, 'profile_background_color': u'000000', 'id_str': u'30186818', 'profile_background_image_url': u'http://a0.twimg.com/images/themes/theme1/bg.png', 'screen_name': u'amacinho', 'lang': u'en', 'profile_background_tile': True, 'favourites_count': 0, 'name': u'Ama\\xe7 Herda\\u011fdelen', 'url': u'http://www.herdagdelen.com', 'created_at': datetime.datetime(2009, 4, 10, 8, 40, 43), 'profile_background_image_url_https': u'https://si0.twimg.com/images/themes/theme1/bg.png', 'time_zone': u'Atlantic Time (Canada)', 'protected': False, 'default_profile': False, 'following': False}", "retweeted": "False", "in_reply_to_status_id_str": "None", "coordinates": "None", "source_url": "http://www.quora.com/", "source": "Quora", "in_reply_to_status_id": "None", "in_reply_to_screen_name": "None", "in_reply_to_user_id": "None", "in_reply_to_user_id_str": "None", "place": "None", "created_at": "2012-03-10 15:25:42", "retweet_count": "0", "geo": "None", "id": "178501892547158016", "possibly_sensitive": "False", "id_str": "178501892547158016"}


--Get friends of a user
echo "30186818" | python2.6 get_friends_by_id.py 2>/dev/null | head -10

30186818        64484817
30186818        19073409
30186818        4488
30186818        41091883
30186818        176235525
30186818        58039559
30186818        39497992
30186818        154275339
30186818        16684046
30186818        34347535

--Get followers of a user by id:

echo "30186818" | python2.6 get_followers_by_id.py 2>/dev/null | wc -l
86

--Get profiles of a users by screen name:

echo "amacinho" | python2.6 get_profiles_by_screen_name.py 2>/dev/null

{"follow_request_sent": "False", "profile_use_background_image": "False", "id": "30186818", "verified": "False", "profile_image_url_https": "https://si0.twimg.com/profile_images/1348692482/cappello__normal.jpg", "profile_sidebar_fill_color": "DDEEF6", "profile_text_color": "333333", "followers_count": "86", "protected": "False", "location": "Cambridge, MA", "default_profile_image": "False", "listed_count": "3", "utc_offset": "-14400", "statuses_count": "87", "description": "Complex systems researcher with an interest in text mining and using social media to extract daily routines of people: http://www.tweetolife.com", "friends_count": "69", "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme1/bg.png", "profile_link_color": "0084B4", "profile_image_url": "http://a0.twimg.com/profile_images/1348692482/cappello__normal.jpg", "notifications": "False", "show_all_inline_media": "False", "geo_enabled": "False", "profile_background_color": "000000", "id_str": "30186818", "profile_background_image_url": "http://a0.twimg.com/images/themes/theme1/bg.png", "name": "Ama\u00e7 Herda\u011fdelen", "lang": "en", "following": "False", "profile_background_tile": "True", "favourites_count": "0", "screen_name": "amacinho", "url": "http://www.herdagdelen.com", "created_at": "2009-04-10 08:40:43", "contributors_enabled": "False", "time_zone": "Atlantic Time (Canada)", "profile_sidebar_border_color": "2b2b2b", "default_profile": "False", "is_translator": "False"}

About

A set of Python scripts for processing Twitter-based data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages