本文整理汇总了Python中twitdao.Twitdao.hacked_search方法的典型用法代码示例。如果您正苦于以下问题:Python Twitdao.hacked_search方法的具体用法?Python Twitdao.hacked_search怎么用?Python Twitdao.hacked_search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitdao.Twitdao
的用法示例。
在下文中一共展示了Twitdao.hacked_search方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from twitdao import Twitdao [as 别名]
# 或者: from twitdao.Twitdao import hacked_search [as 别名]
def get(self):
q = self.param("q")
page = self.param("page")
token = md.get_default_access_token()
if not token:
self.redirect("/settings")
return
td = Twitdao(token)
token_user = td.users_show_by_id(user_id=token.user_id)
owner_user = token_user
searchd = None
timeline = []
if q:
searchd = td.hacked_search(q.encode("utf-8"), page=page)
timeline = searchd["statuses"]
self.render(
"hacked_search.html",
{
"token": token,
"token_user": token_user,
"owner_user": owner_user,
"q": q,
"since_id": timeline[0]["id_str"] if type(timeline) == list and len(timeline) > 0 else None,
"search_data": searchd,
},
)
示例2: get
# 需要导入模块: from twitdao import Twitdao [as 别名]
# 或者: from twitdao.Twitdao import hacked_search [as 别名]
def get(self, slug):
q = self.param('q')
since_id=self.param('since_id')
page=self.param('page')
token = md.get_default_access_token()
if not token:
self.write(json.dumps({
'success':False,
'info':'Token error.'
}))
return
td = Twitdao(token)
token_user = td.users_show_by_id(user_id = token.user_id)
owner_user = token_user
searchd=td.hacked_search(q.encode('utf-8'), since_id, page)
timeline=searchd['statuses']
count=0
next_params={'q':q}
if slug=='refresh':
if type(timeline) == list and len(timeline):
next_params['since_id'] = str(timeline[0]['id'])
else:
next_params['since_id'] = str(since_id)
elif slug=='more':
next_params['page'] = searchd['next_page']
count = len(timeline)
tweets=self.render('ajax/hacked_search.html', {
'token':token,
'token_user':token_user,
'owner_user':owner_user,
'timeline':timeline,
},out=False)
self.write(json.dumps({
'success':True,
'info':'OK',
'tweets':tweets,
'params':next_params,
'count':count,
'href': '/a/search?%s' % urlencode({'page':searchd['next_page'], 'q':q.encode('utf-8')})
}))