码迷,mamicode.com
首页 > 编程语言 > 详细

Python 获取新浪微博的热门话题 (API)

时间:2014-06-28 07:51:56      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:数据挖掘   新浪微博   

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

‘‘‘
Created on 2014-06-27
@author: guaguastd

‘‘‘

import json


# Refer to http://blog.csdn.net/guaguastd/article/details/33664443

from login import weibo_login


# sina weibo basic secret information
APP_KEY = ‘‘ # app key
APP_SECRET = ‘‘ # app secret
REDIRECT_URL = ‘‘
USER_NAME = ‘‘
USER_PASSWD = ‘‘
    
# get weibo_api to access sina api
weibo_api = weibo_login(APP_KEY=APP_KEY, APP_SECRET=APP_SECRET, REDIRECT_URL=REDIRECT_URL, USER_NAME=USER_NAME, USER_PASSWD=USER_PASSWD)

# get trends by hourly, by daily, by weekly
while 1:
    choice = int(raw_input("\ninput choice to get trends (1 means hourly, 2 means daily, 3 means weekly, 0 to quit):"))
    if choice == 0:
        break
    elif choice == 1:
        print ‘Hourly trends are as follow:\r‘
        hourly_trends = weibo_api.trends.hourly.get()
        print json.dumps(hourly_trends, indent=1)
    elif choice == 2:
        print ‘Daily trends are as follow:\r‘
        daily_trends = weibo_api.trends.daily.get()
        print json.dumps(daily_trends, indent=1)
    elif choice == 3:
        print ‘Weekly trends are as follow:\r‘
        weekly_trends = weibo_api.trends.weekly.get()
        print json.dumps(weekly_trends, indent=1)

Python 获取新浪微博的热门话题 (API),布布扣,bubuko.com

Python 获取新浪微博的热门话题 (API)

标签:数据挖掘   新浪微博   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!