热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Python获取新浪微博的最新公共微博实例分享

API:statusespublic_timeline返回最新的200条公共微博,返回结果非完全实时CODE:#!usrbinpython#-*-coding:utf-8-*-Createdon2014-

API:

statuses/public_timeline 返回最新的200条公共微博,返回结果非完全实时

CODE:

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

'''
Created on 2014-7-3
@author: guaguastd
@name: statuses_public_timeline.py
'''

def public_timeline(weibo_api, count):
 
 #public_timeline = weibo_api.statuses.public_timeline.get(count=count)
 public_timeline = weibo_api.statuses__public_timeline(count=count) 
 statuses = public_timeline['statuses']
 return statuses

if __name__ == '__main__':
 
 # import json
 import json
 
 # import login, 
 from login import weibo_login

 # get the twitter access api
 weibo_api = weibo_login()
 
 # get the new 200 weibo
 cOntent= public_timeline(weibo_api, 200)
 print json.dumps(content, indent=1)


RESULT:

['cc7c9d31fc797802960c84822c3654f3']
[
 {
 "reposts_count": 0, 
 "truncated": false, 
 "text": "\u5982\u679c\u4f60\u4e5f\u6709\u75d8\u75d8 \u75d8\u5370 \u6bdb\u5b54\u7c97\u5927 \u6697\u6c89\u6591\u70b9 \u5e72\u71e5 \u7ea2\u8840\u4e1d \u51fa\u6cb9\u9ed1\u5934 \u9ed1\u773c\u5708 \u773c\u888b \u62a4\u7406 \u51cf\u80a5 \u7b49\u7b49\u53ef\u4ee5\u52a0\u8001\u5e08QQ:1817712253\u4e00\u8d77\u5b66\u4e60", 
 "visible": {
 "type": 0, 
 "list_id": 0
 }, 
 "in_reply_to_status_id": "", 
 "bmiddle_pic": "http://ww3.sinaimg.cn/bmiddle/d1a02cb3jw1ehz8g6t1m6j20c90cdq3n.jpg", 
 "id": 3728143255299328, 
 "thumbnail_pic": "http://ww3.sinaimg.cn/thumbnail/d1a02cb3jw1ehz8g6t1m6j20c90cdq3n.jpg", 
 "mid": "3728143255299328", 
 "source": "\u76ae\u76ae\u65f6\u5149\u673a", 
 "attitudes_count": 0, 
 "in_reply_to_screen_name": "", 
 "pic_urls": [
 {
 "thumbnail_pic": "http://ww3.sinaimg.cn/thumbnail/d1a02cb3jw1ehz8g6t1m6j20c90cdq3n.jpg"
 }
 ], 
 "in_reply_to_user_id": "", 
 "darwin_tags": [], 
 "favorited": false, 
 "original_pic": "http://ww3.sinaimg.cn/large/d1a02cb3jw1ehz8g6t1m6j20c90cdq3n.jpg", 
 "idstr": "3728143255299328", 
 "user": {
 "bi_followers_count": 252, 
 "domain": "", 
 "avatar_large": "http://tp4.sinaimg.cn/3516935347/180/40057950890/0", 
 "verified_source": "", 
 "ptype": 0, 
 "statuses_count": 419, 
 "allow_all_comment": true, 
 "id": 3516935347, 
 "verified_reason_url": "", 
 "city": "1", 
 "province": "43", 
 "block_app": 0, 
 "follow_me": false, 
 "verified_reason": "", 
 "followers_count": 420, 
 "location": "\u6e56\u5357 \u957f\u6c99", 
 "verified_trade": "", 
 "mbtype": 0, 
 "verified_source_url": "", 
 "profile_url": "u/3516935347", 
 "block_word": 0, 
 "avatar_hd": "http://ww3.sinaimg.cn/crop.54.22.120.120.1024/d1a02cb3gw1ehkk32gwyfj205k05k3yq.jpg", 
 "star": 0, 
 "description": "", 
 "friends_count": 1085, 
 "online_status": 0, 
 "mbrank": 0, 
 "allow_all_act_msg": false, 
 "profile_image_url": "http://tp4.sinaimg.cn/3516935347/50/40057950890/0", 
 "idstr": "3516935347", 
 "verified": false, 
 "geo_enabled": true, 
 "class": 1, 
 "screen_name": "\u8425\u517b\u7f8e\u5bb9\u8bb2\u5e08\u5c0f\u8fea", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "\u8425\u517b\u7f8e\u5bb9\u8bb2\u5e08\u5c0f\u8fea", 
 "url": "", 
 "gender": "f", 
 "created_at": "Fri Jun 07 10:40:15 +0800 2013", 
 "worldcup_guess": 0, 
 "verified_type": -1, 
 "following": false
 }, 
 "geo": null, 
 "created_at": "Thu Jul 03 07:01:20 +0800 2014", 
 "mlevel": 0, 
 "comments_count": 1
 }, 
 {
 "reposts_count": 0, 
 "truncated": false, 
 "text": "\u301012\u661f\u5ea7\u8001\u516c\u7684\u4f18\u70b9\u3011\u767d\u7f8a\uff1a\u4fdd\u62a4\u4f60\u7684\u52c7\u58eb\uff1b\u91d1\u725b\uff1a\u4e0d\u6d6a\u8d39\u3001\u4e13\u4e00\uff1b\u53cc\u5b50\uff1a\u806a\u660e\u5e7d\u9ed8\uff1b\u5de8\u87f9\uff1a\u6e29\u67d4\u4f53\u8d34\uff1b\u72ee\u5b50\uff1a\u80fd\u4f9d\u9760\u7684\u5927\u6811\uff1b\u5904\u5973\uff1a\u7231\u505a\u5bb6\u52a1\uff1b\u5929\u79e4\uff1a\u813e\u6c14\u6e29\u548c\uff1b\u5929\u874e\uff1a\u5584\u89e3\u4eba\u610f\uff1b\u5c04\u624b\uff1a\u70ed\u60c5\u5927\u5ea6\uff1b\u6469\u7faf\uff1a\u8d23\u4efb\u611f\uff0c\u6301\u5bb6\uff1b\u6c34\u74f6\uff1a\u5236\u9020\u6d6a\u6f2b\uff1b\u53cc\u9c7c\uff1a\u542c\u8bdd", 
 "visible": {
 "type": 0, 
 "list_id": 0
 }, 
 "in_reply_to_status_id": "", 
 "bmiddle_pic": "http://ww3.sinaimg.cn/bmiddle/005z8hcejw1ehz8g6u4jfj30f20m8mzr.jpg", 
 "id": 3728143254878451, 
 "thumbnail_pic": "http://ww3.sinaimg.cn/thumbnail/005z8hcejw1ehz8g6u4jfj30f20m8mzr.jpg", 
 "mid": "3728143254878451", 
 "source": "\u76ae\u76ae\u65f6\u5149\u673a", 
 "attitudes_count": 0, 
 "in_reply_to_screen_name": "", 
 "pic_urls": [
 {
 "thumbnail_pic": "http://ww3.sinaimg.cn/thumbnail/005z8hcejw1ehz8g6u4jfj30f20m8mzr.jpg"
 }
 ], 
 "in_reply_to_user_id": "", 
 "darwin_tags": [], 
 "favorited": false, 
 "original_pic": "http://ww3.sinaimg.cn/large/005z8hcejw1ehz8g6u4jfj30f20m8mzr.jpg", 
 "idstr": "3728143254878451", 
 "user": {
 "bi_followers_count": 6, 
 "domain": "", 
 "avatar_large": "http://tp3.sinaimg.cn/5099808650/180/5693729982/0", 
 "verified_source": "", 
 "ptype": 0, 
 "statuses_count": 838, 
 "allow_all_comment": true, 
 "id": 5099808650, 
 "verified_reason_url": "", 
 "city": "5", 
 "province": "11", 
 "block_app": 0, 
 "follow_me": false, 
 "verified_reason": "", 
 "followers_count": 170, 
 "location": "\u5317\u4eac \u671d\u9633\u533a", 
 "verified_trade": "", 
 "mbtype": 0, 
 "verified_source_url": "", 
 "profile_url": "u/5099808650", 
 "block_word": 0, 
 "avatar_hd": "http://ww3.sinaimg.cn/crop.0.0.170.170.1024/005z8hcejw1efwksyxddwj304q04qa9x.jpg", 
 "star": 0, 
 "description": "", 
 "friends_count": 561, 
 "online_status": 0, 
 "mbrank": 0, 
 "allow_all_act_msg": false, 
 "profile_image_url": "http://tp3.sinaimg.cn/5099808650/50/5693729982/0", 
 "idstr": "5099808650", 
 "verified": false, 
 "geo_enabled": true, 
 "class": 1, 
 "screen_name": "\u7231\u5c31\u4e0d\u6015\u5371\u9669", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "\u7231\u5c31\u4e0d\u6015\u5371\u9669", 
 "url": "", 
 "gender": "f", 
 "created_at": "Tue Apr 29 17:10:14 +0800 2014", 
 "worldcup_guess": 0, 
 "verified_type": -1, 
 "following": false
 }, 
 "geo": null, 
 "created_at": "Thu Jul 03 07:01:20 +0800 2014", 
 "mlevel": 0, 
 "comments_count": 0
 }, 
 {
 "darwin_tags": [], 
 "favorited": false, 
 "mid": "3728143254878339", 
 "in_reply_to_user_id": "", 
 "truncated": false, 
 "text": "\u90ed\u5fb7\u7eb2 \u4e8e\u8c26 2012\u6211\u8981\u5e78\u798f http://t.cn/z0kupX1", 
 "created_at": "Thu Jul 03 07:01:20 +0800 2014", 
 "mlevel": 0, 
 "reposts_count": 0, 
 "idstr": "3728143254878339", 
 "visible": {
 "type": 0, 
 "list_id": 0
 }, 
 "attitudes_count": 0, 
 "pic_urls": [], 
 "in_reply_to_screen_name": "", 
 "user": {
 "bi_followers_count": 14, 
 "domain": "", 
 "avatar_large": "http://tp4.sinaimg.cn/5119417731/180/5696057764/1", 
 "verified_source": "", 
 "ptype": 0, 
 "statuses_count": 144, 
 "allow_all_comment": true, 
 "id": 5119417731, 
 "verified_reason_url": "", 
 "city": "1000", 
 "province": "100", 
 "block_app": 0, 
 "follow_me": false, 
 "verified_reason": "", 
 "followers_count": 137, 
 "location": "\u5176\u4ed6", 
 "verified_trade": "", 
 "mbtype": 0, 
 "verified_source_url": "", 
 "profile_url": "u/5119417731", 
 "block_word": 0, 
 "avatar_hd": "http://ww2.sinaimg.cn/crop.0.0.120.120.1024/005AsypJjw1egrq4a029bj303c03ct8j.jpg", 
 "star": 0, 
 "description": "\u4e16\u754c\u4e0a\u90a3\u4e9b\u6700\u5bb9\u6613\u7684\u4e8b\u60c5\u4e2d\uff0c\u62d6\u5ef6\u65f6\u95f4\u6700\u4e0d\u8d39\u529b\u3002", 
 "friends_count": 183, 
 "online_status": 0, 
 "mbrank": 0, 
 "allow_all_act_msg": false, 
 "profile_image_url": "http://tp4.sinaimg.cn/5119417731/50/5696057764/1", 
 "idstr": "5119417731", 
 "verified": false, 
 "geo_enabled": true, 
 "class": 1, 
 "screen_name": "\u521asir\u768410000\u5929\u542c\u5988\u5988\u7684\u8bdd\u9759\u599e", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "\u521asir\u768410000\u5929\u542c\u5988\u5988\u7684\u8bdd\u9759\u599e", 
 "url": "", 
 "gender": "m", 
 "created_at": "Sat May 10 17:55:53 +0800 2014", 
 "worldcup_guess": 0, 
 "verified_type": -1, 
 "following": false
 }, 
 "in_reply_to_status_id": "", 
 "comments_count": 0, 
 "geo": null, 
 "id": 3728143254878339, 
 "source": "vivo_Xplay"
 }, 
 {
 "reposts_count": 0, 
 "truncated": false, 
 "text": "\u8fd9\u4e48\u591a\u7684\u6f02\u4eae\u65e5\u97e9\u6b27\u7f8e\u6742\u5fd7\u6b3eYY~~>>>>>>\u559c\u6b22\u70b9\u8fd9\u91cc\uff1ahttp://t.cn/RvESDA6", 
 "visible": {
 "type": 0, 
 "list_id": 0
 }, 
 "in_reply_to_status_id": "", 
 "bmiddle_pic": "http://ww3.sinaimg.cn/bmiddle/e9820066jw1ehz8g71g90j20c80gjwgk.jpg", 
 "id": 3728143254489321, 
 "thumbnail_pic": "http://ww3.sinaimg.cn/thumbnail/e9820066jw1ehz8g71g90j20c80gjwgk.jpg", 
 "mid": "3728143254489321", 
 "source": "\u5fae\u535a\u624b\u673a\u7248", 
 "attitudes_count": 0, 
 "in_reply_to_screen_name": "", 
 "pic_urls": [
 {
 "thumbnail_pic": "http://ww3.sinaimg.cn/thumbnail/e9820066jw1ehz8g71g90j20c80gjwgk.jpg"
 }
 ], 
 "in_reply_to_user_id": "", 
 "darwin_tags": [], 
 "favorited": false, 
 "original_pic": "http://ww3.sinaimg.cn/large/e9820066jw1ehz8g71g90j20c80gjwgk.jpg", 
 "idstr": "3728143254489321", 
 "user": {
 "bi_followers_count": 44, 
 "domain": "", 
 "avatar_large": "http://tp3.sinaimg.cn/3917611110/180/5680332659/0", 
 "verified_source": "", 
 "ptype": 0, 
 "statuses_count": 16879, 
 "allow_all_comment": true, 
 "id": 3917611110, 
 "verified_reason_url": "", 
 "city": "1000", 
 "province": "71", 
 "block_app": 0, 
 "follow_me": false, 
 "verified_reason": "", 
 "followers_count": 292, 
 "location": "\u53f0\u6e7e", 
 "verified_trade": "", 
 "mbtype": 0, 
 "verified_source_url": "", 
 "profile_url": "u/3917611110", 
 "block_word": 0, 
 "avatar_hd": "http://ww3.sinaimg.cn/crop.0.2.346.346.1024/e9820066jw1eaxb6we10wj209m09rgn1.jpg", 
 "star": 0, 
 "description": "", 
 "friends_count": 1091, 
 "online_status": 1, 
 "mbrank": 0, 
 "allow_all_act_msg": false, 
 "profile_image_url": "http://tp3.sinaimg.cn/3917611110/50/5680332659/0", 
 "idstr": "3917611110", 
 "verified": false, 
 "geo_enabled": true, 
 "class": 1, 
 "screen_name": "\u6d41\u884c\u7f8e\u642d\u6742\u5fd7", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "\u6d41\u884c\u7f8e\u642d\u6742\u5fd7", 
 "url": "", 
 "gender": "f", 
 "created_at": "Sun Nov 24 17:10:30 +0800 2013", 
 "worldcup_guess": 0, 
 "verified_type": -1, 
 "following": false
 }, 
 "geo": null, 
 "created_at": "Thu Jul 03 07:01:20 +0800 2014", 
 "mlevel": 0, 
 "comments_count": 0
 }, 
 {
 "darwin_tags": [], 
 "favorited": false, 
 "mid": "3728143251104938", 
 "in_reply_to_user_id": "", 
 "truncated": false, 
 "text": "\u708e\u708e\u590f\u65e5\uff0c\u60f3\u60f3\u81ea\u5df1\u90a3\u4e0d\u582a\u56de\u9996\u7684\u201c\u9017\u6bd4\u201d\u4e8b\uff0c\u7ed9\u8fd9\u4e2a\u70ed\u7684\u60f3\u5c4e\u7684\u5b63\u8282\u964d\u964d\u6e29\u4e5f\u4e0d\u5931\u4e3a\u4e00\u4e2a\u597d\u529e\u6cd5~~\u5c31\u7b97\u673a\u667a\u5982\u6211\u6709\u7684\u65f6\u5019\u4e5f\u62b5\u4e0d\u8fc7\u60b2\u50ac\u547d\u8fd0\u7684\u6298\u78e8\uff01 http://t.cn/Rvufq4y", 
 "created_at": "Thu Jul 03 07:01:20 +0800 2014", 
 "mlevel": 0, 
 "reposts_count": 0, 
 "idstr": "3728143251104938", 
 "visible": {
 "type": 0, 
 "list_id": 0
 }, 
 "attitudes_count": 0, 
 "pic_urls": [], 
 "in_reply_to_screen_name": "", 
 "user": {
 "bi_followers_count": 3, 
 "domain": "", 
 "avatar_large": "http://tp2.sinaimg.cn/2776200377/180/5686197056/1", 
 "verified_source": "", 
 "ptype": 0, 
 "statuses_count": 855, 
 "allow_all_comment": true, 
 "id": 2776200377, 
 "verified_reason_url": "", 
 "city": "6", 
 "province": "43", 
 "block_app": 0, 
 "follow_me": false, 
 "verified_reason": "", 
 "followers_count": 106, 
 "location": "\u6e56\u5357 \u5cb3\u9633", 
 "verified_trade": "", 
 "mbtype": 0, 
 "verified_source_url": "", 
 "profile_url": "u/2776200377", 
 "block_word": 0, 
 "avatar_hd": "http://ww2.sinaimg.cn/crop.0.0.200.200.1024/a57974b9jw1ed3s4if74zj205l05kwen.jpg", 
 "star": 0, 
 "description": "", 
 "friends_count": 166, 
 "online_status": 0, 
 "mbrank": 0, 
 "allow_all_act_msg": false, 
 "profile_image_url": "http://tp2.sinaimg.cn/2776200377/50/5686197056/1", 
 "idstr": "2776200377", 
 "verified": false, 
 "geo_enabled": true, 
 "class": 1, 
 "screen_name": "\u75db\u5fc3\u7684\u5b88\u62a4", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "\u75db\u5fc3\u7684\u5b88\u62a4", 
 "url": "", 
 "gender": "m", 
 "created_at": "Tue May 22 09:36:02 +0800 2012", 
 "worldcup_guess": 0, 
 "verified_type": -1, 
 "following": false
 }, 
 "in_reply_to_status_id": "", 
 "comments_count": 0, 
 "geo": null, 
 "id": 3728143251104938, 
 "source": "vivo_Xplay"
 }
]

原文地址:http://blog.csdn.net/guaguastd/article/details/36618701


推荐阅读
  • Node.js 教程第五讲:深入解析 EventEmitter(事件监听与发射机制)
    本文将深入探讨 Node.js 中的 EventEmitter 模块,详细介绍其在事件监听与发射机制中的应用。内容涵盖事件驱动的基本概念、如何在 Node.js 中注册和触发自定义事件,以及 EventEmitter 的核心 API 和使用方法。通过本教程,读者将能够全面理解并熟练运用 EventEmitter 进行高效的事件处理。 ... [详细]
  • 使用cpphttplib构建HTTP服务器以处理带有查询参数的URL请求 ... [详细]
  • Android 图像色彩处理技术详解
    本文详细探讨了 Android 平台上的图像色彩处理技术,重点介绍了如何通过模仿美图秀秀的交互方式,利用 SeekBar 实现对图片颜色的精细调整。文章展示了具体的布局设计和代码实现,帮助开发者更好地理解和应用图像处理技术。 ... [详细]
  • 进程(Process)是指计算机中程序对特定数据集的一次运行活动,是系统资源分配与调度的核心单元,构成了操作系统架构的基础。在早期以进程为中心的计算机体系结构中,进程被视为程序的执行实例,其状态和控制信息通过任务描述符(task_struct)进行管理和维护。本文将深入探讨进程的概念及其关键数据结构task_struct,解析其在操作系统中的作用和实现机制。 ... [详细]
  • 通过整合JavaFX与Swing,我们成功地将现有的Swing应用程序组件进行了现代化改造。此次升级不仅提升了用户界面的美观性和交互性,还确保了与原有Swing应用程序的无缝集成,为开发高质量的Java桌面应用提供了坚实的基础。 ... [详细]
  • 本文介绍了Android动画的基本概念及其主要类型。Android动画主要包括三种形式:视图动画(也称为补间动画或Tween动画),主要通过改变视图的属性来实现动态效果;帧动画,通过顺序播放一系列预定义的图像来模拟动画效果;以及属性动画,通过对对象的属性进行平滑过渡来创建更加复杂的动画效果。每种类型的动画都有其独特的应用场景和实现方式,开发者可以根据具体需求选择合适的动画类型。 ... [详细]
  • 计算 n 叉树中各节点子树的叶节点数量分析 ... [详细]
  • 在使用群报数小程序进行高效接龙与统计时,可以通过创建 `LinkedList` 对象并利用 `for` 循环生成指定数量的 `Person` 对象,为每个人员分配唯一的编号,并将其添加到 `LinkedList` 集合中。这一过程确保了数据的有序性和高效管理,便于后续的接龙和统计操作。此外,该小程序还支持实时更新和查看参与人员的状态,进一步提升了活动组织的便利性和准确性。 ... [详细]
  • 本文首先对信息漏洞的基础知识进行了概述,重点介绍了几种常见的信息泄露途径。具体包括目录遍历、PHPINFO信息泄露以及备份文件的不当下载。其中,备份文件下载涉及网站源代码、`.bak`文件、Vim缓存文件和`DS_Store`文件等。目录遍历漏洞的详细分析为后续深入研究奠定了基础。 ... [详细]
  • 本题库精选了Java核心知识点的练习题,旨在帮助学习者巩固和检验对Java理论基础的掌握。其中,选择题部分涵盖了访问控制权限等关键概念,例如,Java语言中仅允许子类或同一包内的类访问的访问权限为protected。此外,题库还包括其他重要知识点,如异常处理、多线程、集合框架等,全面覆盖Java编程的核心内容。 ... [详细]
  • 本文探讨了在Android应用中实现动态滚动文本显示控件的优化方法。通过详细分析焦点管理机制,特别是通过设置返回值为`true`来确保焦点不会被其他控件抢占,从而提升滚动文本的流畅性和用户体验。具体实现中,对`MarqueeText.java`进行了代码层面的优化,增强了控件的稳定性和兼容性。 ... [详细]
  • 深入解析Python中的循环双向链表数据结构
    本文详细探讨了Python中循环双向链表的数据结构,包括其定义、特点及应用场景。文章首先介绍了循环双向链表的基本概念,随后深入分析了其核心操作,如节点的插入、删除和遍历等。最后,通过具体的Python代码示例,展示了如何高效地实现这些操作,帮助读者全面理解并掌握这一重要数据结构。 ... [详细]
  • 如何在 Java LinkedHashMap 中高效地提取首个或末尾的键值对? ... [详细]
  • 深入解析Gradle中的Project核心组件
    在Gradle构建系统中,`Project` 是一个核心组件,扮演着至关重要的角色。通过使用 `./gradlew projects` 命令,可以清晰地列出当前项目结构中包含的所有子项目,这有助于开发者更好地理解和管理复杂的多模块项目。此外,`Project` 对象还提供了丰富的配置选项和生命周期管理功能,使得构建过程更加灵活高效。 ... [详细]
  • 利用Swiss数据集进行多元线性回归分析,首先通过散点图矩阵(pairs plot)初步探索各变量之间的关系。接着,绘制残差图以评估模型的拟合效果和假设条件的合理性,进一步诊断和验证模型的有效性。通过这些图形工具,可以更深入地理解模型的性能和潜在问题。 ... [详细]
author-avatar
幸福得味道2011_122
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有