Ejemplo n.º 1
0
    def check(self, list_data, offset, cnt):
        """
        :param list_data: 请求返回的结果
        :param offset:
        :return: 带着本次请求的参数和结果一起过安检
        请求失败导致安检不通过 安检提醒人重新操作手机 操作完之后再次发起请求
        不排除还是会失败  继续调用自己
        """
        if list_data != 'req_data_error':
            stop_and_start.check({'crawler': '历史文章列表', 'msg': 'success'})
        else:
            stop_and_start.check({
                'crawler': '历史文章列表',
                'msg': 'req_data_error'
            })
            self.wx_req_data_list = rd.tidy()
            while len(self.wx_req_data_list) == 0:
                self.wx_req_data_list = rd.tidy()
                from utils.front import notification
                notification('没有发现参数', '参数错误', _type='error')
                time.sleep(3)

            list_data = Crawler(offset, self.wx_req_data_list[0]).run()
            self.check(list_data, offset, cnt)
        return list_data
Ejemplo n.º 2
0
 def new_step(self):
     """
     :return: 发送新步骤开始
     """
     from utils.front import notification
     notification(
         title='采集进入新阶段',
         message=self.process['steps'][self.process['current']]['title'],
         _type='success',
         duration=5)
     self.process['current'] += 1
     self.send_process()
Ejemplo n.º 3
0
 def run(self):
     #
     try:
         self.delete_collection()
         self.delete_crawler_log()
         self.delete_html()
         self.delete_index()
     except:
         from utils.base import logger
         logger.warning('删除数据遇到一个警告')
     from utils.front import notification
     notification(self.nickname, '删除完成 刷新页面公众号消失', 'success')
Ejemplo n.º 4
0
def execute_command(command):
    """
    :param command:
    :return: 参数使用 ' - ' 间隔
    """
    from utils.front import notification
    cmd = command.split(' - ')[0]
    cmd_args = command.split(' - ')[1:]
    if cmd not in commands:
        notification(command, '不支持的命令', _type='error')
    else:
        notification(command, '开始执行', _type='success')
        # 线程背后运行
        from threading import Thread
        Thread(target=commands[cmd].run, args=(cmd, cmd_args)).start()
Ejemplo n.º 5
0
 def run(self):
     from utils.front import notification
     data_gen = self.prepare_data()
     df = self.create_dataframe(data_gen)
     self.create_excel(df)
     notification(self.nickname, '导出Excel完成', 'success')
     import subprocess
     from instance import PLATFORM
     if PLATFORM == 'osx':
         subprocess.call(['open', EXCEL_OUTPUT_FOLDER])
     else:
         if PLATFORM == 'win':
             subprocess.call(
                 ['explorer',
                  EXCEL_OUTPUT_FOLDER.replace('/', '\\')])
Ejemplo n.º 6
0
 def run(self):
     from utils.front import notification
     # notification(self.nickname+' 如果文章数多 需要更长时间 请耐心等待', '正在导出Excel', 'warning')
     data_gen = self.prepare_data()
     df = self.create_dataframe(data_gen)
     self.create_excel(df)
     notification(self.nickname, '导出Excel完成', 'success')
     import subprocess
     # mac 和win 系统下打开文件夹的命令不同
     from instance import PLATFORM
     if PLATFORM == 'osx':
         subprocess.call(['open', EXCEL_OUTPUT_FOLDER])
     elif PLATFORM == 'win':
         subprocess.call(
             ['explorer',
              EXCEL_OUTPUT_FOLDER.replace('/', '\\')])
Ejemplo n.º 7
0
    def check(self, reading_data, item):
        """
        :return: 带着本次请求的参数和结果一起过安检
        请求失败导致安检不通过 安检提醒人重新操作手机 操作完之后再次发起请求
        不排除还是会失败  继续调用自己 反正想办法让其获得成功的请求  最后返回成功的请求
        """
        if reading_data != 'req_data_error':
            stop_and_start.check({'crawler': '阅读数据', 'msg': 'success'})
        else:
            stop_and_start.check({'crawler': '阅读数据', 'msg': 'req_data_error'})
            self.wx_req_data_list = rd.tidy()
            while len(self.wx_req_data_list) == 0:
                self.wx_req_data_list = rd.tidy()
                from utils.front import notification
                notification('没有发现参数', '参数错误', _type='error')
                time.sleep(3)

            reading_data = Crawler(item[1], item[2],
                                   self.wx_req_data_list[0]).run()
            self.check(reading_data, item)
        return reading_data
Ejemplo n.º 8
0
 def run(self):
     self.delete_collection()
     self.delete_crawler_log()
     self.delete_html()
     from utils.front import notification
     notification(self.nickname, '删除完成', 'success')