当前位置: 首页>>代码示例>>Python>>正文


Python APIClient.statuses__home_timeline方法代码示例

本文整理汇总了Python中weibo.APIClient.statuses__home_timeline方法的典型用法代码示例。如果您正苦于以下问题:Python APIClient.statuses__home_timeline方法的具体用法?Python APIClient.statuses__home_timeline怎么用?Python APIClient.statuses__home_timeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weibo.APIClient的用法示例。


在下文中一共展示了APIClient.statuses__home_timeline方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_code

# 需要导入模块: from weibo import APIClient [as 别名]
# 或者: from weibo.APIClient import statuses__home_timeline [as 别名]
def get_code(ACCOUNT,PASSWORD):
        #get url
  client = APIClient(app_key = APP_KEY,app_secret = APP_SECRET,redirect_uri=CALLBACK_URL)
	url = client.get_authorize_url()
	
        #get code
	conn = httplib.HTTPSConnection('api.weibo.com')
	postdata = urllib.urlencode     ({'client_id':APP_KEY,'response_type':'code','redirect_uri':CALLBACK_URL,'action':'submit','userId':ACCOUNT,'passwd':PASSWORD,'isLoginSina':0,'from':'','regCallback':'','state':'','ticket':'','withOfficalFlag':0})
	conn.request('POST','/oauth2/authorize',postdata,{'Referer':url,'Content-Type': 'application/x-www-form-urlencoded'})
	res = conn.getresponse()
	location = res.getheader('location')
	code = location.split('=')[1]
	conn.close()

	#get client		
	r = client.request_access_token(code)
	access_token = r.access_token 
	expires_in = r.expires_in 
	client.set_access_token(access_token, expires_in)
	
	all_tmp = client.users__show(uid = client.account__get_uid()['uid'])
	rz7.PIC_URL = all_tmp['profile_image_url']
	rz7.NAME = all_tmp['screen_name']
	all = {}
	#a count
	flag = 0
	data = []
	all = client.statuses__home_timeline(count = 200)
	d = dict(all)
	
	#fobj = open("api_data","w")

	tar = ''
	
	for i in range(len(d['statuses'])):	
		if 'bmiddle_pic' in d['statuses'][i]:
			tmp = {}
			tmp['name'] = d['statuses'][i]['user']['screen_name']
			tmp['text'] = d['statuses'][i]['text']
			tmp['picture'] = d['statuses'][i]['bmiddle_pic']
			tmp['face'] = d['statuses'][i]['user']['profile_image_url']

			fn = tar + (str)(flag) + '.jpg'
			urlretrieve(d['statuses'][i]['bmiddle_pic'],fn)
			flag = flag + 1
			data.append(tmp)	
	return data,flag
开发者ID:lianrzh,项目名称:DIP-with-ML-in-weibo,代码行数:49,代码来源:API_weibo.py


注:本文中的weibo.APIClient.statuses__home_timeline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。