本文整理汇总了Python中fetcher.Fetcher.get_ranked_pages方法的典型用法代码示例。如果您正苦于以下问题:Python Fetcher.get_ranked_pages方法的具体用法?Python Fetcher.get_ranked_pages怎么用?Python Fetcher.get_ranked_pages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fetcher.Fetcher
的用法示例。
在下文中一共展示了Fetcher.get_ranked_pages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from fetcher import Fetcher [as 别名]
# 或者: from fetcher.Fetcher import get_ranked_pages [as 别名]
def handle(self):
# self.request is the TCP socket connected to the client
data = self.request.recv(1024).strip()
if data.startswith("GET /favicon.ico"):
return
print '--------------data---------------- ' + data
query_components = get_query_parameters(data)
print "query %s" % query_components
# just send back the same data, but upper-cased
# date_days_ago = Fetcher.DEFAULT_DATE
result = {"result":"empty"}
if "days" in query_components:
from fetcher import Fetcher
date_days_ago = float(query_components["days"][0])
result = Fetcher.get_ranked_pages(date_days_ago)
elif "category" in query_components:
sort = "score"
if "sort" in query_components:
sort = query_components["sort"][0]
result = social_db.read_from_spikedate(query_components["category"][0], sort)
elif "channel" in query_components:
channel = query_components["channel"][0]
result = get_channel_serving.sort_channel_by_field(channel, max_count=100, remove_adult=False)
elif "translate" in query_components:
text = query_components["translate"][0]
if self.token_expired is None or self.token_expired:
self.update_token()
self.token_expired = False
if "from" in query_components and "to" in query_components:
from_lang = query_components["from"][0]
to_lang = query_components["to"][0]
result = MTPythonSampleCode.translate(self.final_token, textToTranslate=text, fromLangCode=from_lang, toLangCode=to_lang)
else:
result = MTPythonSampleCode.translate(self.final_token, text)
self.request.sendall(json.dumps(result, encoding="utf-8", ensure_ascii=False))