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

Python 获取新浪微博指定用户的微博列表

2014-07-18 07:49 886 查看
CODE:

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

'''
Created on 2014-7-18
@author: guaguastd
@name: statusesUserTimeline.py
'''

if __name__ == '__main__':

# import json
import json

# get weibo_api to access sina api
from sinaWeiboLogin import sinaWeiboLogin
sinaWeiboApi = sinaWeiboLogin()

# import sinaWeoboStatuses
from sinaWeiboStatuses import userTimeline

# get the new 200 weibo
content = userTimeline(sinaWeiboApi, 200)
print json.dumps(content, indent=1)


RESULT:

[
{
"darwin_tags": [],
"favorited": false,
"mid": "3731076012679100",
"in_reply_to_user_id": "",
"truncated": false,
"text": "Python \u63d0\u53d6\u65b0\u6d6a\u516c\u5171\u5fae\u535a\u4e2d\u8f6c\u8f7d\u6b21\u6570\u6700\u591a\u7684\u5fae\u535a\u8f6c\u8f7d\u6570\uff0c\u7528\u6237\u540d\uff0c\u5185\u5bb9 http://t.cn/RvFMuci", "created_at": "Fri Jul 11 09:15:04 +0800 2014",
"mlevel": 0,
"reposts_count": 0,
"idstr": "3731076012679100",
"visible": {
"type": 0,
"list_id": 0
},
"attitudes_count": 0,
"pic_urls": [],
"in_reply_to_screen_name": "",
"user": {
"bi_followers_count": 0,
"domain": "",
"avatar_large": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"verified_source": "",
"ptype": 0,
"statuses_count": 4,
"allow_all_comment": true,
"id": 3286717353,
"verified_reason_url": "",
"city": "8",
"province": "11",
"block_app": 0,
"follow_me": false,
"verified_reason": "",
"followers_count": 1,
"location": "\u5317\u4eac \u6d77\u6dc0\u533a",
"verified_trade": "",
"mbtype": 0,
"verified_source_url": "",
"profile_url": "u/3286717353",
"block_word": 0,
"avatar_hd": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"star": 0,
"description": "",
"friends_count": 4,
"online_status": 1,
"mbrank": 0,
"allow_all_act_msg": false,
"profile_image_url": "http://tp2.sinaimg.cn/3286717353/50/0/1",
"idstr": "3286717353",
"verified": false,
"geo_enabled": true,
"class": 1,
"screen_name": "beyondzhou8",
"lang": "zh-cn",
"weihao": "",
"remark": "",
"favourites_count": 0,
"name": "beyondzhou8",
"url": "",
"gender": "m",
"created_at": "Tue Aug 20 00:41:09 +0800 2013",
"verified_type": -1,
"following": false
},
"in_reply_to_status_id": "",
"comments_count": 0,
"geo": null,
"id": 3731076012679100,
"source": "<a href=\"http://weibo.com/\" rel=\"nofollow\">\u5fae\u535a weibo.com</a>"
},
{
"darwin_tags": [],
"favorited": false,
"mid": "3730684251828947",
"in_reply_to_user_id": "",
"truncated": false,
"text": "Python \u5bf9\u65b0\u6d6a\u5fae\u535a\u7684\u5143\u7d20 (Word, Screen Name)\u7684\u8bcd\u6c47\u591a\u6837\u6027\u5206\u6790 http://t.cn/Rvk5vp3", "created_at": "Thu Jul 10 07:18:21 +0800 2014",
"mlevel": 0,
"reposts_count": 0,
"idstr": "3730684251828947",
"visible": {
"type": 0,
"list_id": 0
},
"attitudes_count": 0,
"pic_urls": [],
"in_reply_to_screen_name": "",
"user": {
"bi_followers_count": 0,
"domain": "",
"avatar_large": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"verified_source": "",
"ptype": 0,
"statuses_count": 4,
"allow_all_comment": true,
"id": 3286717353,
"verified_reason_url": "",
"city": "8",
"province": "11",
"block_app": 0,
"follow_me": false,
"verified_reason": "",
"followers_count": 1,
"location": "\u5317\u4eac \u6d77\u6dc0\u533a",
"verified_trade": "",
"mbtype": 0,
"verified_source_url": "",
"profile_url": "u/3286717353",
"block_word": 0,
"avatar_hd": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"star": 0,
"description": "",
"friends_count": 4,
"online_status": 1,
"mbrank": 0,
"allow_all_act_msg": false,
"profile_image_url": "http://tp2.sinaimg.cn/3286717353/50/0/1",
"idstr": "3286717353",
"verified": false,
"geo_enabled": true,
"class": 1,
"screen_name": "beyondzhou8",
"lang": "zh-cn",
"weihao": "",
"remark": "",
"favourites_count": 0,
"name": "beyondzhou8",
"url": "",
"gender": "m",
"created_at": "Tue Aug 20 00:41:09 +0800 2013",
"verified_type": -1,
"following": false
},
"in_reply_to_status_id": "",
"comments_count": 0,
"geo": null,
"id": 3730684251828947,
"source": "<a href=\"http://weibo.com/\" rel=\"nofollow\">\u5fae\u535a weibo.com</a>"
},
{
"darwin_tags": [],
"favorited": false,
"mid": "3730665490725827",
"in_reply_to_user_id": "",
"truncated": false,
"text": "Python \u5bf9Twitter\u4e2d\u6307\u5b9a\u8bdd\u9898\u7684\u88ab\u8f6c\u8f7dTweet\u6570\u91cf\u7684\u9891\u8c31\u5206\u6790 http://t.cn/RvkGP6L", "created_at": "Thu Jul 10 06:03:48 +0800 2014",
"mlevel": 0,
"reposts_count": 0,
"idstr": "3730665490725827",
"visible": {
"type": 0,
"list_id": 0
},
"attitudes_count": 0,
"pic_urls": [],
"in_reply_to_screen_name": "",
"user": {
"bi_followers_count": 0,
"domain": "",
"avatar_large": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"verified_source": "",
"ptype": 0,
"statuses_count": 4,
"allow_all_comment": true,
"id": 3286717353,
"verified_reason_url": "",
"city": "8",
"province": "11",
"block_app": 0,
"follow_me": false,
"verified_reason": "",
"followers_count": 1,
"location": "\u5317\u4eac \u6d77\u6dc0\u533a",
"verified_trade": "",
"mbtype": 0,
"verified_source_url": "",
"profile_url": "u/3286717353",
"block_word": 0,
"avatar_hd": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"star": 0,
"description": "",
"friends_count": 4,
"online_status": 1,
"mbrank": 0,
"allow_all_act_msg": false,
"profile_image_url": "http://tp2.sinaimg.cn/3286717353/50/0/1",
"idstr": "3286717353",
"verified": false,
"geo_enabled": true,
"class": 1,
"screen_name": "beyondzhou8",
"lang": "zh-cn",
"weihao": "",
"remark": "",
"favourites_count": 0,
"name": "beyondzhou8",
"url": "",
"gender": "m",
"created_at": "Tue Aug 20 00:41:09 +0800 2013",
"verified_type": -1,
"following": false
},
"in_reply_to_status_id": "",
"comments_count": 0,
"geo": null,
"id": 3730665490725827,
"source": "<a href=\"http://weibo.com/\" rel=\"nofollow\">\u5fae\u535a weibo.com</a>"
},
{
"darwin_tags": [],
"favorited": false,
"mid": "3687339672990740",
"in_reply_to_user_id": "",
"truncated": false,
"text": "Hi",
"created_at": "Wed Mar 12 16:42:28 +0800 2014",
"mlevel": 0,
"reposts_count": 3,
"idstr": "3687339672990740",
"visible": {
"type": 0,
"list_id": 0
},
"attitudes_count": 0,
"pic_urls": [],
"in_reply_to_screen_name": "",
"user": {
"bi_followers_count": 0,
"domain": "",
"avatar_large": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"verified_source": "",
"ptype": 0,
"statuses_count": 4,
"allow_all_comment": true,
"id": 3286717353,
"verified_reason_url": "",
"city": "8",
"province": "11",
"block_app": 0,
"follow_me": false,
"verified_reason": "",
"followers_count": 1,
"location": "\u5317\u4eac \u6d77\u6dc0\u533a",
"verified_trade": "",
"mbtype": 0,
"verified_source_url": "",
"profile_url": "u/3286717353",
"block_word": 0,
"avatar_hd": "http://tp2.sinaimg.cn/3286717353/180/0/1",
"star": 0,
"description": "",
"friends_count": 4,
"online_status": 1,
"mbrank": 0,
"allow_all_act_msg": false,
"profile_image_url": "http://tp2.sinaimg.cn/3286717353/50/0/1",
"idstr": "3286717353",
"verified": false,
"geo_enabled": true,
"class": 1,
"screen_name": "beyondzhou8",
"lang": "zh-cn",
"weihao": "",
"remark": "",
"favourites_count": 0,
"name": "beyondzhou8",
"url": "",
"gender": "m",
"created_at": "Tue Aug 20 00:41:09 +0800 2013",
"verified_type": -1,
"following": false
},
"in_reply_to_status_id": "",
"comments_count": 3,
"geo": null,
"id": 3687339672990740,
"source": "<a href=\"http://weibo.com/\" rel=\"nofollow\">\u5fae\u535a weibo.com</a>"
}
]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: