Beispiel #1
0
    def taskWork(self, dict_json):
        """
        具体任务的工作方法,主要调用爬虫完成数据爬取
        :param dict_json:
        :return:
        """
        token = dict_json['token']
        try:
            client = SpiderMain(dict_json)
            logger.info("需要抓取图片验证码,token:%s" % token)
            p1 = threading.Thread(target=client.crawl,
                                  args=("user", ),
                                  name="crawl")
            # p2 = threading.Thread(target=client.crawl, args=("auto",))
            p1.start()
            time.sleep(5)
            p2 = threading.Thread(target=client.br.dc.clean(), name="clean")
            p2.start()
            p2.join()
            p1.join()
            # p2.start()

        except Exception:
            s = traceback.format_exc()
            logger.error(s)
Beispiel #2
0
    def taskWork(self, dict_json):
        """
        具体任务的工作方法,主要调用爬虫完成数据爬取
        :param dict_json:
        :return:
        """
        token = dict_json['token']
        try:
            client = SpiderMain(dict_json)
            logger.info("不需要抓取图片验证码,token:%s" % token)
            p1 = threading.Thread(target=client.crawl, args=("auto",))
            # p2 = threading.Thread(target=client.crawl, args=("auto",))
            p1.start()
            # p2.start()

        except Exception:
            s = traceback.format_exc()
            sendMail(s, '*****@*****.**')
            logger.error(s)