您的位置:首页 > 编程语言 > Python开发

Python 提取Twitter用户的个人简介

2014-07-26 06:50 351 查看
CODE:

#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Created on 2014-7-26
@author: guaguastd
@name: resolve_user_profile.py
'''

if __name__ == '__main__':

# import json
import json

# import login, see http://blog.csdn.net/guaguastd/article/details/31706155 from login import twitter_login

# import get_user_profile
from user import get_user_profile

# get the twitter access api
twitter_api = twitter_login()

# sample usage
print json.dumps(get_user_profile(twitter_api, screen_names=["SocialWebMining", "ptwobrussell", "beyondzhouping"]), indent=1)
#print json.dumps(get_user_profile(twitter_api, user_ids=[132373965, 1564763678, 13085242]), indent=1)


RESULT:

{
"BeyondZhouPing": {
"follow_request_sent": false,
"profile_use_background_image": true,
"default_profile_image": true,
"id": 1564763678,
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
"verified": false,
"profile_text_color": "333333",
"profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
"profile_sidebar_fill_color": "DDEEF6",
"entities": {
"description": {
"urls": []
}
},
"followers_count": 0,
"profile_sidebar_border_color": "C0DEED",
"id_str": "1564763678",
"profile_background_color": "C0DEED",
"listed_count": 0,
"status": {
"lang": "en",
"favorited": false,
"entities": {
"symbols": [],
"user_mentions": [],
"hashtags": [],
"urls": []
},
"contributors": null,
"truncated": false,
"text": "Hello",
"created_at": "Fri Jul 25 22:37:33 +0000 2014",
"retweeted": false,
"in_reply_to_status_id_str": null,
"coordinates": null,
"in_reply_to_user_id_str": null,
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"in_reply_to_status_id": null,
"in_reply_to_screen_name": null,
"id_str": "492800853623836672",
"place": null,
"retweet_count": 0,
"geo": null,
"id": 492800853623836672,
"favorite_count": 0,
"in_reply_to_user_id": null
},
"is_translation_enabled": false,
"utc_offset": null,
"statuses_count": 2,
"description": "",
"friends_count": 5,
"location": "",
"profile_link_color": "0084B4",
"profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
"following": false,
"geo_enabled": true,
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
"screen_name": "BeyondZhouPing",
"lang": "en",
"profile_background_tile": false,
"favourites_count": 0,
"name": "BeyondZhou",
"notifications": false,
"url": null,
"created_at": "Wed Jul 03 03:38:46 +0000 2013",
"contributors_enabled": false,
"time_zone": null,
"protected": false,
"default_profile": true,
"is_translator": false
},
"ptwobrussell": {
"follow_request_sent": false,
"profile_use_background_image": true,
"default_profile_image": false,
"id": 13085242,
"profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/112353046/twitter-1.4.2.gif",
"verified": false,
"profile_text_color": "333333",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/378800000365424290/cbdedf17eb021ce95ddce059a90c1787_normal.jpeg",
"profile_sidebar_fill_color": "F7F7F7",
"entities": {
"url": {
"urls": [
{
"url": "http://t.co/AzFoM9TBPO",
"indices": [
0,
22
],
"expanded_url": "http://MiningTheSocialWeb.com",
"display_url": "MiningTheSocialWeb.com"
}
]
},
"description": {
"urls": []
}
},
"followers_count": 1642,
"profile_sidebar_border_color": "888888",
"id_str": "13085242",
"profile_background_color": "888888",
"listed_count": 141,
"status": {
"contributors": null,
"truncated": false,
"text": "An upcoming Nashville Computer Science Meetup  entitled \"Big O Notation...for the Uninitiated\" - http://t.co/iEK01MfASJ", "in_reply_to_status_id": null,
"id": 491417973492441090,
"favorite_count": 2,
"source": "<a href=\"https://about.twitter.com/products/tweetdeck\" rel=\"nofollow\">TweetDeck</a>",
"retweeted": false,
"coordinates": null,
"entities": {
"symbols": [],
"user_mentions": [],
"hashtags": [],
"urls": [
{
"url": "http://t.co/iEK01MfASJ",
"indices": [
97,
119
],
"expanded_url": "http://bit.ly/Uo6DNt",
"display_url": "bit.ly/Uo6DNt"
}
]
},
"in_reply_to_screen_name": null,
"id_str": "491417973492441090",
"retweet_count": 1,
"in_reply_to_user_id": null,
"favorited": false,
"geo": null,
"in_reply_to_user_id_str": null,
"possibly_sensitive": false,
"lang": "en",
"created_at": "Tue Jul 22 03:02:29 +0000 2014",
"in_reply_to_status_id_str": null,
"place": null
},
"is_translation_enabled": false,
"utc_offset": -18000,
"statuses_count": 1468,
"description": "Computer Scientist. Technologist. CrossFitter. Triathlete. Author.",
"friends_count": 156,
"location": "Franklin, TN",
"profile_link_color": "EE8336",
"profile_image_url": "http://pbs.twimg.com/profile_images/378800000365424290/cbdedf17eb021ce95ddce059a90c1787_normal.jpeg",
"following": false,
"geo_enabled": false,
"profile_background_image_url": "http://pbs.twimg.com/profile_background_images/112353046/twitter-1.4.2.gif",
"screen_name": "ptwobrussell",
"lang": "en",
"profile_background_tile": false,
"favourites_count": 863,
"name": "Matthew Russell",
"notifications": false,
"url": "http://t.co/AzFoM9TBPO",
"created_at": "Tue Feb 05 08:16:12 +0000 2008",
"contributors_enabled": false,
"time_zone": "Central Time (US & Canada)",
"protected": false,
"default_profile": false,
"is_translator": false
},
"SocialWebMining": {
"follow_request_sent": false,
"profile_use_background_image": true,
"default_profile_image": false,
"id": 132373965,
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme5/bg.gif",
"verified": false,
"profile_text_color": "3E4415",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/1154493071/Picture_7_normal.png",
"profile_sidebar_fill_color": "99CC33",
"entities": {
"url": {
"urls": [
{
"url": "http://t.co/CJfJDyM6ki",
"indices": [
0,
22
],
"expanded_url": "http://miningthesocialweb.com",
"display_url": "miningthesocialweb.com"
}
]
},
"description": {
"urls": [
{
"url": "http://t.co/U0VmWrXpB9",
"indices": [
31,
53
],
"expanded_url": "http://bit.ly/MiningTheSocialWeb2E",
"display_url": "bit.ly/MiningTheSocia\u2026"
}
]
}
},
"followers_count": 3517,
"profile_sidebar_border_color": "829D5E",
"id_str": "132373965",
"profile_background_color": "352726",
"listed_count": 180,
"status": {
"contributors": null,
"truncated": false,
"text": "GMail now has a nice API that facilitates data mining your inbox - http://t.co/hMc2nXdcFx", "in_reply_to_status_id": null,
"id": 482194826813657088,
"favorite_count": 4,
"source": "<a href=\"https://about.twitter.com/products/tweetdeck\" rel=\"nofollow\">TweetDeck</a>",
"retweeted": false,
"coordinates": null,
"entities": {
"symbols": [],
"user_mentions": [],
"hashtags": [],
"urls": [
{
"url": "http://t.co/hMc2nXdcFx",
"indices": [
67,
89
],
"expanded_url": "http://bit.ly/1pmT8w8",
"display_url": "bit.ly/1pmT8w8"
}
]
},
"in_reply_to_screen_name": null,
"id_str": "482194826813657088",
"retweet_count": 4,
"in_reply_to_user_id": null,
"favorited": false,
"geo": null,
"in_reply_to_user_id_str": null,
"possibly_sensitive": false,
"lang": "en",
"created_at": "Thu Jun 26 16:13:00 +0000 2014",
"in_reply_to_status_id_str": null,
"place": null
},
"is_translation_enabled": false,
"utc_offset": null,
"statuses_count": 758,
"description": "Get the source code at GitHub: http://t.co/U0VmWrXpB9", "friends_count": 0,
"location": "",
"profile_link_color": "D02B55",
"profile_image_url": "http://pbs.twimg.com/profile_images/1154493071/Picture_7_normal.png",
"following": false,
"geo_enabled": false,
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme5/bg.gif",
"screen_name": "SocialWebMining",
"lang": "en",
"profile_background_tile": false,
"favourites_count": 30,
"name": "MiningTheSocialWeb",
"notifications": false,
"url": "http://t.co/CJfJDyM6ki",
"created_at": "Tue Apr 13 02:10:40 +0000 2010",
"contributors_enabled": false,
"time_zone": null,
"protected": false,
"default_profile": false,
"is_translator": false
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: