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


Python Setting.webSite方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import webSite [as 别名]
 def get(self):
     website = Setting().all().fetch(1)
     if 0 == len(website):
         w = Setting()
         w.webSite = "http://im.zxxsbook.com"
         w.put()
         website.append(w)
     web = website[0]
     self.searchRSS(web.webSite + "/RssSource")
开发者ID:wangjian2254,项目名称:newsgroup,代码行数:11,代码来源:urlmanage.py

示例2: handle_result

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import webSite [as 别名]
    def handle_result(self, rpc, rssSources, url):
        try:
            result = rpc.get_result()
            if result.status_code == 200:
                html = result.content
                rsslist = feedparser.parse(html)
                alist = []
                for rss in rsslist.entries:
                    try:
                        alist.append((rss.title, rss.link, rss.description))
                    except Exception, e:
                        logging.error("rss jiexi" + str(e))
                newContent = []
                contentobj = ContentsObj().all().filter("rss =", rssSources).fetch(1)
                if not contentobj:
                    contentobj = ContentsObj()
                    contentobj.rss = rssSources
                else:
                    contentobj = contentobj[0]
                nowNewsList = json.loads(contentobj.contentdata)
                for title, link, desc in alist:
                    link = link.strip()
                    if link not in nowNewsList:
                        newContent.append((link, title, desc, []))
                rpcs = []
                notediclist = []
                for linkyuanzu in newContent:
                    pam = {}
                    rpc = urlfetch.create_rpc(deadline=50)
                    rpc.callback = self.rpc2_callback(rpc, rssSources, linkyuanzu, nowNewsList[-10:], pam)
                    urlfetch.make_fetch_call(
                        rpc, linkyuanzu[0], headers={"User-Agent": "Mozilla/5.0"}, follow_redirects=True
                    )
                    rpcs.append(rpc)
                    notediclist.append(pam)
                for rpc in rpcs:
                    rpc.wait()
                website = Setting().all().fetch(1)
                if len(website) == 0:
                    web = Setting()
                    web.webSite = "http://localhoat:8888"
                    web.put()
                else:
                    web = website[0]
                allpam = {}
                tempNewList = []
                allpam["notenum"] = str(len(notediclist))
                for i, pam in enumerate(notediclist):
                    if pam:
                        tempNewList.append(newContent[i][0])
                        if not rssSources.isfilterImg:
                            for num in range(pam["imgnum"]):
                                allpam[str(i) + "img" + str(num)] = pam["img" + str(num)]
                        allpam[str(i) + "code"] = pam["code"]
                        allpam[str(i) + "title"] = pam["title"]
                        allpam[str(i) + "content"] = pam["content"]
                        allpam[str(i) + "username"] = pam["username"]
                if not notediclist:
                    return
                login_url = web.webSite + "/RssMsg"
                login_data = urllib.urlencode(allpam)
                #                logging.info('pam:'+str(allpam))
                result = urlfetch.fetch(
                    url=login_url,
                    payload=login_data,
                    method=urlfetch.POST,
                    headers={
                        "Content-Type": "application/x-www-form-urlencoded",
                        "User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6",
                    },
                    follow_redirects=False,
                    deadline=50,
                )
                if result.status_code == 200:
                    nowNewsList.extend(tempNewList)
                    contentobj.contentdata = json.dumps(nowNewsList[-60:])
                    contentobj.put()
                else:
                    #                    linkyuanzu[3].append(False)
                    logging.error("send news failure !" + linkyuanzu[0])
        #                for linkyuanzu in newContent:
        #                    if linkyuanzu[3]:
        #                        nowNewsList.append(linkyuanzu[0])

        except Exception, e:
            logging.error("0000" + str(e) + url)
开发者ID:wangjian2254,项目名称:newsgroup,代码行数:88,代码来源:urlmanage.py


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