94采集器破解线程限制 – 解线程源码

__init__.py

新建文件 ,内容如下

import os
from flask import Flask
from config import Config
from datetime import timedelta
from app.logs import log
from app.helper import filehelper, taskhelper
from app.helper.schehelper import scheduler


def app():
    try:
        path = os.getcwd()
        tpath = '{0}//templates'.format(path.replace("\\", "//"))
        spath = '{0}//static'.format(path.replace("\\", "//"))
        appflask = Flask(__name__)  # , template_folder=tpath, static_folder=spath
        appflask.config.from_object(Config())
        # 自动重载模板文件
        appflask.jinja_env.auto_reload = True
        appflask.config['TEMPLATES_AUTO_RELOAD'] = True
        # 设置静态文件缓存过期时间
        appflask.config['SEND_FILE_MAX_AGE_DEFAULT'] = timedelta(seconds=1)
        appflask.config['JSON_AS_ASCII'] = False  # 这个配置可以确保http请求返回的json数据中正常显示中文
        读取基础配置()
        #scheduler.init_app(appflask)
        scheduler.start()
        return appflask
    except Exception as e:
        msg = 'app-{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                                    e.__traceback__.tb_lineno)
        log.错误日志(msg)

def 读取基础配置():
    try:
        系统设置 = filehelper.读INI("系统设置.ini", "系统设置", "系统设置")
        Config.系统设置 = eval(系统设置)
        大类设置 = filehelper.读INI("大类设置.ini", "大类设置", "大类设置")
        Config.一级分类 = 大类设置.strip('\n').split('\n')
        小类设置 = filehelper.读INI("小类设置.ini", "小类设置", "小类设置")
        Config.二级分类 = 小类设置.strip('\n').split('\n')
        频道设置 = filehelper.读INI("频道设置.ini", "频道设置", "频道设置")
        Config.频道 = 频道设置.strip('\n').split('\n')
        连载设置 = filehelper.读INI("连载设置.ini", "连载设置", "连载设置")
        Config.连载 = 连载设置.strip('\n').split('\n')
        标识设置 = filehelper.读INI("标识设置.ini", "标识设置", "标识设置")
        Config.标识 = 标识设置.strip('\n').split('\n')
        自定内容 = filehelper.读INI("自定内容.ini", "自定内容", "自定内容")
        Config.自定内容 = 自定内容
        UA设置 = filehelper.读INI("UA设置.ini", "UA设置", "UA设置")
        Config.UA = UA设置.split('\n')
        代理设置 = filehelper.读INI("代理设置.ini", "代理设置", "代理设置")
        Config.代理 = 代理设置.strip('\n').split('\n')
        邮件设置 = filehelper.读INI("邮件设置.ini", "邮件设置", "邮件设置")
        Config.邮件 = eval(邮件设置)
        规则列表 = filehelper.读取任务列表()
        for item in 规则列表:
            if item.startswith('任务'):
                任务ID = item.replace('任务', '').replace('.ini', '')
                任务字符串 = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'taskinfo')
                任务信息 = eval(任务字符串)
                taskhelper.添加任务(任务信息)
    except Exception as e:
        msg = '读取基础配置-{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                                    e.__traceback__.tb_lineno)
        log.错误日志(msg)

新建 task.py文件,内容如下

# -*- coding: UTF-8 -*-
import json
import base64
import datetime
from config import Config
from app.helper import filehelper, commonhelper, taskhelper
from flask import request, render_template


def 查询任务列表():
    try:
        规则列表 = filehelper.读取任务列表()
        返回值 = []
        for item in 规则列表:
            if item.startswith('任务'):
                任务ID = item.replace('任务', '').replace('.ini', '')
                规则ID = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'taskname')
                任务名称 = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'taskname')
                任务类型 = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'taskType')
                任务状态 = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'taskstatus')
                任务时间间隔 = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'tasktime')
                采集内容 = commonhelper.获取当前采集信息(任务ID)
                最后运行时间 = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'gxsj')
                返回值.append({
                    "任务ID": 任务ID,
                    "规则ID": 规则ID,
                    "任务名称": 任务名称,
                    "任务类型": 任务类型,
                    "任务状态": 任务状态,
                    "任务时间间隔": 任务时间间隔,
                    "采集内容": 采集内容,
                    "最后运行时间": 最后运行时间
                })
        return '{"code":0,"msg":"", "count":' + str(len(返回值)) + ', "data": ' + json.dumps(返回值) + '}'
    except Exception as e:
        return '{"code":0,"msg":"' + e + '","count":0,"data":[]}'


def 添加任务():
    try:
        taskid = str(request.form['taskid'])
        ruleid = str(request.form['ruleid'])
        taskname = str(request.form['taskname'])
        tasktime = str(request.form['tasktime'])
        taksmode = str(request.form['taksmode'])
        taskType = str(request.form['taskType'])
        bookid = str(request.form['bookid'])
        startid = str(request.form['startid'])
        endid = str(request.form['endid'])
        startpage = str(request.form['startpage'])
        endpage = str(request.form['endpage'])
        pagelist = str(request.form['pagelist'])
        isimg = str(request.form['isimg'])
        isinfo = str(request.form['isinfo'])
        ismark = str(request.form['ismark'])
        sizerestoration = str(request.form['sizerestoration'])
        colletime = str(request.form['colletime'])
        retrynum = str(request.form['retrynum'])
        retrytime = str(request.form['retrytime'])
        useragent = str(request.form['useragent'])
        contrastmethod = str(request.form['contrastmethod'])
        an = str(request.form['an'])
        cn = str(request.form['cn'])
        yj = str(request.form['yj'])
        dl = str(request.form['dl'])
        dlinfo = str(request.form['dlinfo'])
        cookies = str(request.form['cookies'])
        bcjbt = str(request.form['bcjbt'])
        minichapter = str(request.form['minichapter'])
        bookurl = str(request.form['bookurl'])
        booklisturl = str(request.form['booklisturl'])
        maxchapter = str(request.form['maxchapter'])
        iscf5 = str(request.form['iscf5'])
        是否添加 = False
        if (taskid == None) | (taskid == 'None') | (taskid == ''):
            taskid = datetime.datetime.now().strftime("%Y%m%d%H%m%f")
            是否添加 = True
        任务信息 = {
            "taskid": taskid,
            "ruleid": ruleid,
            "taskname": taskname,
            "tasktime": tasktime,
            "taksmode": taksmode,
            "taskType": taskType,
            "bookid": bookid,
            "bookurl": bookurl,
            "startid": startid,
            "endid": endid,
            "booklisturl": booklisturl,
            "startpage": startpage,
            "endpage": endpage,
            "pagelist": pagelist,
            "isimg": isimg,
            "isinfo": isinfo,
            "ismark": ismark,
            "sizerestoration": sizerestoration,
            "colletime": colletime,
            "retrynum": retrynum,
            "retrytime": retrytime,
            "useragent": useragent,
            "contrastmethod": contrastmethod,
            "an": an,
            "cn": cn,
            "yj": yj,
            "dl": dl,
            "dlinfo": dlinfo,
            "cookies": cookies,
            "bcjbt": bcjbt,
            "minichapter": minichapter,
            "maxchapter": maxchapter,
            "iscf5":iscf5
        }
        if filehelper.写入任务INI(taskid, taskid, 任务信息):
            if 是否添加:
                taskhelper.添加任务(任务信息)
            else:
                taskhelper.修改任务(任务信息)
                taskhelper.获取任务信息(taskid)
            return '保存成功!'
        else:
            return '保存失败!'
    except Exception as e:
        msg = '{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                             e.__traceback__.tb_lineno)
        return msg


def 查询任务信息():
    try:
        类型 = str(request.args.get('type'))
        任务信息 = {}
        规则信息 = []
        if 类型 == 'add':
            pass
        elif 类型 == 'up':
            任务ID = str(request.args.get('taskid'))
            任务字符串 = filehelper.读INI('任务{0}.ini'.format(任务ID), 任务ID, 'taskinfo')
            任务信息 = eval(任务字符串)
        规则列表 = filehelper.读取规则列表()
        for item in 规则列表:
            规则ID = filehelper.读INI('规则.ini', item, 'ruleid')
            规则名称 = filehelper.读INI('规则.ini', item, 'rulename')
            规则信息.append({"v": 规则ID, "t": 规则名称})
        return render_template("task.html", info=任务信息, 规则=规则信息, UserAgent=Config.UA)
    except Exception as e:
        msg = '{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                             e.__traceback__.tb_lineno)
        return render_template("msg.html", info=msg)


def 启动任务():
    try:
        任务ID = str(request.args.get('taskid'))
        if filehelper.修改INI('任务{0}.ini'.format(任务ID), 任务ID, "taskstatus", "开启"):
            return '启动成功!'
        else:
            return '启动失败!'
    except Exception as e:
        msg = '{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                             e.__traceback__.tb_lineno)
        return msg


def 暂停任务():
    try:
        任务ID = str(request.args.get('taskid'))
        if filehelper.修改INI('任务{0}.ini'.format(任务ID), 任务ID, "taskstatus", "暂停"):
            return '暂停成功!'
        else:
            return '暂停失败!'
    except Exception as e:
        msg = '{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                             e.__traceback__.tb_lineno)
        return msg


def 删除任务信息():
    try:
        任务ID = str(request.args.get('taskid'))
        if filehelper.删除任务INI(任务ID):
            taskhelper.删除任务(任务ID)
            return '删除成功!'
        else:
            return '删除失败!'
    except Exception as e:
        msg = '{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                             e.__traceback__.tb_lineno)
        return msg


def 批量删除任务信息():
    try:
        任务ID = str(request.form['taskId'])
        任务列表 = 任务ID.split('|')
        成功数量 = 0
        失败数量 = 0
        for item in 任务列表:
            if filehelper.删除任务INI(任务ID):
                taskhelper.删除任务(任务ID)
                成功数量 = 成功数量 + 1
            else:
                失败数量 = 失败数量 + 1
        return '成功删除{0}条,失败{1}条!'.format(成功数量, 失败数量)
    except Exception as e:
        msg = '{0},文件地址:{1},错误行号:{2}'.format(e, e.__traceback__.tb_frame.f_globals["__file__"],
                                             e.__traceback__.tb_lineno)
        return msg

task.py文件放入app/view文件夹

原来对应的pyc文件可以删除。

替换完成后重启应用服务器即可。

无错源码所有资源来自会员发布以及互联网收集,不代表本站立场,如有侵犯你的权益请联系管理员,站内发信联系 我们会第一时间进行审核删除。站内资源为网友个人学习或测试研究使用,未经原版权作者许可,禁止用于任何商业途径!本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请在下载24小时内删除!


如果遇到付费才可观看的文章,建议升级传奇VIP。全站所有资源任意下免费看”。本站资源少部分采用7z压缩,为防止有人压缩软件不支持7z格式,7z解压,建议下载7-zip,zip、rar解压,建议下载WinRAR如遇解压需要密码,请尝试使用www.wucuoym.com来解压,如若仍有问题,请联系站长。

给TA打赏
共{{data.count}}人
人已打赏
数据抓取

使用Fofa确定网站真实IP地址的小技巧

2023-7-21 17:40:49

数据抓取

一个开源的动态IP代理池  - 爬虫必备神器

2023-9-12 18:35:13

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索