示例#1
0
    def submit_search_request(self,
                              keyword,
                              flags=True,
                              account_id='null',
                              task_id='null'):
        """
        提交详细查询请求,解析详情内容
        :param keyword: 查询输入内容
        :param flags: 查询内容信用代码还是公司名
        :param account_id: 账户id
        :param task_id: 任务id
        :return:
        """
        self.json_result = {}
        self.today = TimeUtils.get_today()
        keyword = keyword.replace('(', u'(').replace(')',
                                                     u')').replace(' ', '')
        mc, xydm = '', ''
        if flags:
            mc = keyword
        else:
            xydm = keyword

        self.tag_a = self.get_tag_a_from_page(keyword)
        if self.tag_a:
            self.json_result['inputCompanyName'] = keyword
            self.json_result['taskId'] = task_id
            self.json_result['accountId'] = account_id
            # self.info('jiben')
            self.get_ying_ye_zhi_zhao()
            # self.info('zhuyaorenyuan')
            try:
                self.get_zhu_yao_ren_yuan()
            except Exception as e:
                self.info(u'主要人员表失败:%s' % e)
                pass
            # self.info('biangeng')
            self.get_bian_geng()
            # self.info('gudong')
            self.get_gu_dong()
            # self.get_gu_quan_chu_zhi()
            # self.get_dong_chan_di_ya()
            # self.get_jing_ying_yi_chang()
            # self.get_chou_cha_jian_cha()
            # self.get_xing_zheng_chu_fa()
            # self.send_msg(json.dumps(self.json_result, ensure_ascii=False))  # 已失效

            self.send_msg_to_kafka(
                json.dumps(self.json_result, ensure_ascii=False))
            return 1
        else:
            return 0
示例#2
0
    def run(self):
        cnt_0 = 0
        cnt_1 = 0
        cnt_2 = 0
        while True:
            sql_1 = "select mc,province from " \
                    "(" \
                    "select * from %s where update_status=-1 limit 30 " \
                    ") t " \
                    "order by RAND() limit 1" % self.src_table
            # print sql_1
            res_1 = MySQL.execute_query(sql_1)
            if len(res_1) > 0:
                mc = res_1[0][0]

                last_update_date = TimeUtils.get_today()

                sql_2 = "update %s set update_status=-2 " \
                        "where mc='%s'" \
                        % (self.src_table, mc)
                MySQL.execute_update(sql_2)
                try:
                    update_status = self.searcher.submit_search_request(
                        keyword=mc)
                    sql_3 = "update %s set update_status=%d, last_update_time=now() " \
                            "where mc='%s'" % \
                            (self.src_table, update_status, mc)
                except Exception, e:
                    self.info(traceback.format_exc(e))
                    update_status = -1
                    self.info(str(e))
                    sql_3 = "update %s set update_status=%d,last_update_time=now() " \
                            "where mc='%s'" % \
                            (self.src_table, update_status, mc)
                MySQL.execute_update(sql_3)
                if update_status == 0:
                    cnt_0 += 1
                elif update_status == 1:
                    cnt_1 += 1
                else:
                    cnt_2 += 1
                self.info(u'查询有结果: %d, 查询无结果: %d, 查询失败:%d' %
                          (cnt_1, cnt_0, cnt_2))
            else:
                self.info(u'更新完毕')
                break
示例#3
0
    def submit_search_request(self,
                              keyword,
                              account_id='null',
                              task_id='null'):
        """
        :param keyword:
        :param flags: {True: 名称查询,False:信用代码查询}
        :param account_id:
        :param task_id:
        :return:
        """

        if check(keyword):
            is_xydm = True
        else:
            is_xydm = False
            keyword = self.process_mc(keyword)
        update_status = 0
        self.json_result.clear()
        # keyword = self.process_mc(keyword)
        self.json_result['accountId'] = account_id
        self.json_result['taskId'] = task_id
        self.today = TimeUtils.get_today()
        self.tag_a = self.get_tag_a_from_page(keyword)
        self.json_result['inputCompanyName'] = self.input_company_name
        # print self.tag_a
        if self.tag_a:
            if is_xydm or self.input_company_name == keyword:
                update_status = 1
            else:
                update_status = 888
            if self.get_ying_ye_zhi_zhao():
                self.get_zhu_yao_ren_yuan()
                self.get_bian_geng()
                self.get_gu_dong()
                # self.get_gu_quan_chu_zhi()
                # self.get_dong_chan_di_ya()
                # self.get_jing_ying_yi_chang()
                # self.get_chou_cha_jian_cha()
                # self.get_xing_zheng_chu_fa()
                self.send_msg_to_kafka(
                    json.dumps(self.json_result, ensure_ascii=False))
            else:
                update_status = -1
        return update_status