Пример #1
0
    def handle2_result(self, rpc, rss, linkyuanzu, oldlist, pam):
        try:
            result = rpc.get_result()
            if result.status_code == 200:

                html = result.content

                if html:
                    oldHtmlList = []
                    for k in oldlist:
                        t = memcache.get(k)
                        if t:
                            oldHtmlList.append(t)
                    #                    logging.info('html:'+html)
                    news, piclist = skinSubThree(oldHtmlList, html, linkyuanzu[1], linkyuanzu[0])
                    #                    news,piclist=skinSubFour(oldHtmlList,html,linkyuanzu[1],linkyuanzu[0])
                    #                    logging.info('news:'+news)

                    imgmap = {}
                    for url in piclist:
                        imgmap[url] = False
                    self.searchPic(imgmap, piclist)
                    imglist = []
                    for url in piclist:
                        if imgmap[url]:
                            imglist.append(url)

                    #                    pam={}
                    #                    piclist=piclist[0:2]
                    pam["imgnum"] = len(imglist)
                    for i in range(len(imglist)):
                        img = imglist[i]
                        pam["img" + str(i)] = img
                    pam["code"] = rss.code
                    pam["title"] = linkyuanzu[1].encode("utf-8")
                    pam["content"] = news.encode("utf-8")
                    pam["username"] = setting.adminname
                    #            if c.rcode:
                    #                pam['rcode']=c.rcode.encode('utf-8')

            #                    logging.info('syncurl:'+login_url)
            else:
                logging.error("500" + linkyuanzu[0] + "rss:" + str(rss.rssUrl))
        except Exception, e:
            logging.error("get html error " + linkyuanzu[0] + "---" + str(e))
Пример #2
0
    def handle2_result(self, rpc, rss, linkyuanzu, oldlist, pam):
        try:
            result = rpc.get_result()
            if result.status_code == 200:
                try:
                    html = result.content.decode("utf-8").strip()
                except:
                    try:
                        html = result.content.decode("gbk").strip()
                    except:
                        try:
                            html = result.content.decode("gb18030").strip()
                        except:
                            html = None

                if html:
                    oldHtmlList = []
                    for k in oldlist:
                        t = memcache.get(k)
                        if t:
                            oldHtmlList.append(t)
                    #                    logging.info('html:'+html)
                    news, piclist = skinSubThree(oldHtmlList, html, linkyuanzu[1], linkyuanzu[0])
                    #                    logging.info('news:'+news)
                    memcache.set(linkyuanzu[0], html, 360000)

                    #                    pam={}
                    pam["imgnum"] = len(piclist)
                    for i in range(len(piclist)):
                        img = piclist[i]
                        pam["img" + str(i)] = img
                    pam["code"] = rss.code
                    pam["title"] = linkyuanzu[1].encode("utf-8")
                    pam["content"] = news.encode("utf-8")
                    pam["username"] = setting.adminname
                    #            if c.rcode:
                    #                pam['rcode']=c.rcode.encode('utf-8')

            #                    logging.info('syncurl:'+login_url)
            else:
                logging.error("500" + linkyuanzu[0] + "rss:" + str(rss.rssUrl))
        except Exception, e:
            logging.error("get html error " + linkyuanzu[0] + "---" + str(e))