當前位置: 首頁>>代碼示例>>Python>>正文


Python Fetcher.get_ranked_pages方法代碼示例

本文整理匯總了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))
開發者ID:razhong,項目名稱:randy,代碼行數:37,代碼來源:social_tcp_handler.py


注:本文中的fetcher.Fetcher.get_ranked_pages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。