Ejemplo n.º 1
0
    def scan_list(self, target, exists):
        """请求参数"""
        par = (['flag', 'true'], ['uuid', target.extra0])
        """抓取关键字"""
        keys = [
            'title', 'author', 'publicTime', 'url', 'clicksCount', 'likeCount',
            'publicTime', 'summary'
        ]

        list = []
        result_list = []

        try:
            raw = RequestHelper.post(NewrankRuler.url,
                                     par,
                                     file_cookie=Configs.newrank_cookie_file)
        except Exception as e:
            import traceback
            msg = traceback.format_exc()
            # print(msg)
            LogGo.warning(msg)
            return (-1, (target, None, None, None))

        try:
            list = ExtraJSON.extra_newrank_wechat_list(raw, keys)
        except:
            return (-1, (target, None, None, None))

        if len(list) > 0:
            list.reverse()

            for item in list:
                if exists.count(item['title']) < 1:
                    result_list.append(item)

            LogGo.debug('newrank list length:' + str(len(result_list)))

        if len(result_list) > 0:
            return (1, (target, list, None, None))
        return (-1, (target, None, None, None))
Ejemplo n.º 2
0
    def send_request(self, result_dic):
        json_dic = dict()
        json_dic['date'] = DateGo.get_current_date()
        json_dic['targetId'] = 'No Target ID!'
        json_dic['rowList'] = [result_dic]

        try:
            LogGo.info("Ready to Post!")

            raw = RequestHelper.post(Configs.fish_data_post_url, json = json_dic)

            preview_dic = result_dic.copy()
            preview_dic['text_not_format_clob'] = 'DUMMY CONTENT'
            preview_dic['text_blob'] = 'DUMMY CONTENT'
            json_dic['rowList'] = preview_dic

            json_str = json.dumps(json_dic)

            LogGo.info("POST CONTENT: " + json_str)
            LogGo.info("POST RESPONSE: " + str(raw))
        except Exception:
            E.out_err()