当前位置:  编程技术>python

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

    来源: 互联网  发布时间:2014-10-08

    本文导语:  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_timel...

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": "u5982u679cu4f60u4e5fu6709u75d8u75d8 u75d8u5370 u6bdbu5b54u7c97u5927 u6697u6c89u6591u70b9 u5e72u71e5 u7ea2u8840u4e1d u51fau6cb9u9ed1u5934 u9ed1u773cu5708 u773cu888b u62a4u7406 u51cfu80a5 u7b49u7b49u53efu4ee5u52a0u8001u5e08QQ:1817712253u4e00u8d77u5b66u4e60", 
 "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": "u76aeu76aeu65f6u5149u673a", 
 "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": "u6e56u5357 u957fu6c99", 
 "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": "u8425u517bu7f8eu5bb9u8bb2u5e08u5c0fu8fea", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "u8425u517bu7f8eu5bb9u8bb2u5e08u5c0fu8fea", 
 "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": "u301012u661fu5ea7u8001u516cu7684u4f18u70b9u3011u767du7f8auff1au4fddu62a4u4f60u7684u52c7u58ebuff1bu91d1u725buff1au4e0du6d6au8d39u3001u4e13u4e00uff1bu53ccu5b50uff1au806au660eu5e7du9ed8uff1bu5de8u87f9uff1au6e29u67d4u4f53u8d34uff1bu72eeu5b50uff1au80fdu4f9du9760u7684u5927u6811uff1bu5904u5973uff1au7231u505au5bb6u52a1uff1bu5929u79e4uff1au813eu6c14u6e29u548cuff1bu5929u874euff1au5584u89e3u4ebau610fuff1bu5c04u624buff1au70edu60c5u5927u5ea6uff1bu6469u7fafuff1au8d23u4efbu611fuff0cu6301u5bb6uff1bu6c34u74f6uff1au5236u9020u6d6au6f2buff1bu53ccu9c7cuff1au542cu8bdd", 
 "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": "u76aeu76aeu65f6u5149u673a", 
 "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": "u5317u4eac u671du9633u533a", 
 "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": "u7231u5c31u4e0du6015u5371u9669", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "u7231u5c31u4e0du6015u5371u9669", 
 "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": "u90edu5fb7u7eb2 u4e8eu8c26 2012u6211u8981u5e78u798f 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": "u5176u4ed6", 
 "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": "u4e16u754cu4e0au90a3u4e9bu6700u5bb9u6613u7684u4e8bu60c5u4e2duff0cu62d6u5ef6u65f6u95f4u6700u4e0du8d39u529bu3002", 
 "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": "u521asiru768410000u5929u542cu5988u5988u7684u8bddu9759u599e", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "u521asiru768410000u5929u542cu5988u5988u7684u8bddu9759u599e", 
 "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": "u8fd9u4e48u591au7684u6f02u4eaeu65e5u97e9u6b27u7f8eu6742u5fd7u6b3eYY~~>>>>>>u559cu6b22u70b9u8fd9u91ccuff1ahttp://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": "u5faeu535au624bu673au7248", 
 "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": "u53f0u6e7e", 
 "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": "u6d41u884cu7f8eu642du6742u5fd7", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "u6d41u884cu7f8eu642du6742u5fd7", 
 "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": "u708eu708eu590fu65e5uff0cu60f3u60f3u81eau5df1u90a3u4e0du582au56deu9996u7684u201cu9017u6bd4u201du4e8buff0cu7ed9u8fd9u4e2au70edu7684u60f3u5c4eu7684u5b63u8282u964du964du6e29u4e5fu4e0du5931u4e3au4e00u4e2au597du529eu6cd5~~u5c31u7b97u673au667au5982u6211u6709u7684u65f6u5019u4e5fu62b5u4e0du8fc7u60b2u50acu547du8fd0u7684u6298u78e8uff01 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": "u6e56u5357 u5cb3u9633", 
 "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": "u75dbu5fc3u7684u5b88u62a4", 
 "lang": "zh-cn", 
 "weihao": "", 
 "remark": "", 
 "favourites_count": 0, 
 "name": "u75dbu5fc3u7684u5b88u62a4", 
 "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


    
 
 

您可能感兴趣的文章:

  • Python使用新浪微博API发送微博的例子
  • python使用新浪微博api上传图片到微博示例
  • python模拟新浪微博登陆功能(新浪微博爬虫)
  • python使用rsa加密算法模块模拟新浪微博登录
  • 使用Python进行新浪微博的mid和url互相转换实例(10进制和62进制互算)
  • python调用新浪微博API项目实践
  • Python namedtuple(命名元组)使用实例
  • python实现的重启关机程序实例
  • Python 3 Tkinter教程之事件Event绑定处理代码实例
  • python调用短信猫控件实现发短信功能实例
  • Python文件操作类操作实例详解
  • python 基础学习第二弹 类属性和实例属性
  • Python实现冒泡,插入,选择排序简单实例
  • Python 时间处理datetime实例
  • Python实现类继承实例
  • Python continue语句用法实例
  • python3编写C/S网络程序实例教程
  • 在python中的socket模块使用代理实例
  • python实现进程间通信简单实例
  • python字典多条件排序方法实例
  • python中enumerate的用法实例解析
  • python解析xml文件实例分享
  • python的绘图工具matplotlib使用实例
  • Python Tkinter简单布局实例教程
  • Python中__call__用法实例
  • 使用Python判断IP地址合法性的方法实例
  • Python中apply函数的用法实例教程
  •  
    本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
    本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • Python获取网页编码的方法及示例代码
  • python 获取文件列表(或是目录例表)
  • Python通过正则表达式获取,去除(过滤)或者替换HTML标签的几种方法
  • python通过scapy获取局域网所有主机mac地址示例
  • python获取网页状态码示例
  • python中使用urllib2获取http请求状态码的代码例子
  • Python获取远程文件大小的函数代码分享
  • python 获取et和excel的版本号
  • linux系统使用python获取内存使用信息脚本分享
  • python 获取本机ip地址的两个方法
  • 使用python 获取进程pid号的方法
  • linux系统使用python获取cpu信息脚本分享
  • python获取糗百图片代码实例
  • python获取beautifulphoto随机某图片代码实例
  • python获取豆瓣电影简介代码分享
  • python 动态获取当前运行的类名和函数名的方法
  • python使用urllib2模块获取gravatar头像实例
  • 使用python编写脚本获取手机当前应用apk的信息
  • python使用ctypes模块调用windowsapi获取系统版本示例
  • linux系统使用python监测网络接口获取网络的输入输出
  • Python获取当前时间的方法
  • Python GUI编程:tkinter实现一个窗口并居中代码
  • 让python同时兼容python2和python3的8个技巧分享
  • Python不使用print而直接输出二进制字符串
  • 使用setup.py安装python包和卸载python包的方法
  • Python中实现json字符串和dict类型的互转
  • 不小心把linux自带的python卸载了,导致安装一个依赖原python的软件不能安装,请问该怎么办?
  • python异常信息堆栈输出到日志文件
  • python读取csv文件示例(python操作csv)
  • python下用os.execl执行centos下的系统时间同步命令ntpdate
  • python基础教程之python消息摘要算法使用示例


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3