|
@@ -0,0 +1,1292 @@
|
|
|
+<template>
|
|
|
+ <!-- 规则列表 -->
|
|
|
+ <div>
|
|
|
+ <div class="title">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6" class="left">
|
|
|
+ <div class="searchBox">
|
|
|
+ <div class="searchTitle">任务规则名:</div>
|
|
|
+ <el-input v-model="searchRuleName" placeholder="请输入任务规则名"></el-input>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="10" class="right">
|
|
|
+ <div class="btnList">
|
|
|
+ <button class="search" @click="goSearch">搜索</button>
|
|
|
+ <button class="reset" @click="goReset">重置</button>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ <!--表格内容 start------------------------------------------------------------>
|
|
|
+ <div class="layerBox">
|
|
|
+ <tableTitle :name="tableDivTitle" />
|
|
|
+ <button class="btn" @click="addCrawlerRule">设置采集规则</button>
|
|
|
+ <el-row>
|
|
|
+ <template>
|
|
|
+ <el-table class="my-table" :data="tableData" style="width: 100%">
|
|
|
+ <el-table-column fixed prop="id" label="编号" width="100">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="name" label="任务规则名" width="">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="arts_count" label="采集个数" width="">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="created_at" label="创建时间" width="">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="updated_at" label="修改时间" width="">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column fixed="right" label="操作" width="385">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div class="listBtnBox">
|
|
|
+ <div class="listDeleteBtn" @click="deleteRow(scope.row.id)"><i
|
|
|
+ class="el-icon-delete"></i>删除</div>
|
|
|
+ <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)"><i
|
|
|
+ class="el-icon-edit-outline"></i>编辑</div>
|
|
|
+
|
|
|
+ <div class="collector" @click="goCollect(scope.row.id, scope.row.status)"
|
|
|
+ v-if="scope.row.status == 0 || scope.row.status == 2">
|
|
|
+ <i class="collectorIcon"></i>采集
|
|
|
+ </div>
|
|
|
+ <div class="collector" @click="toast" v-if="scope.row.status == 4">
|
|
|
+ <i class="collectorIcon"></i>采集
|
|
|
+ </div>
|
|
|
+ <div class="loadingBtn" v-if="scope.row.status == 1">
|
|
|
+ <i class="collectorIcon1 el-icon-loading"></i><span>采集</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="listLookBtn" @click="goLook(scope.row.id, scope.row)"><i
|
|
|
+ class="el-icon-view"></i>查看</div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </template>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ <!--分页 start------------------------------------------------------------>
|
|
|
+ <div class="alignBox" v-show="disabled">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
|
|
+ :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
|
|
|
+ :total="total">
|
|
|
+ </el-pagination>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ <!--分页 end------------------------------------------------------------>
|
|
|
+ <!--表格内容 end------------------------------------------------------------>
|
|
|
+
|
|
|
+ <!-- 弹出框 -->
|
|
|
+ <el-dialog :title="dialogName" :visible.sync="dialogTableVisible" width="50%" :close-on-click-modal="false">
|
|
|
+ <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
|
|
|
+ <div class="one" v-show="this.webType == 1">
|
|
|
+ <div class="dialogText">
|
|
|
+ <el-form-item label="任务规则名:" prop="ruleName" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.ruleName" placeholder="请输入任务规则名"></el-input>
|
|
|
+ <el-tooltip class="item" effect="dark" content="任务规则名,如中国农村网-时政要闻" placement="top-start">
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="第1页网址:" prop="first_url" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.first_url" placeholder="请输入第一页网址"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 一般为网站的栏目页网址,也是文章列表页网址。<br />
|
|
|
+ 若网站内页数为多页,第1页网址如:http://politics.people.com.cn/GB/1024/index1.html(第1页的数字)
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <div class="pageTwo">
|
|
|
+ <el-form-item label="第2页网址:" required class="keywords">
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item prop="second_start">
|
|
|
+ <el-input v-model="ruleForm.second_start" placeholder="请输入网址开头"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item prop="second_num">
|
|
|
+ <el-input v-model="ruleForm.second_num" placeholder="请输入代码页数"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6" class="el_col_6_end">
|
|
|
+ <el-form-item prop="second_end">
|
|
|
+ <el-input v-model="ruleForm.second_end" placeholder="请输入网址结束字符串"
|
|
|
+ class="lastInput"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 网址如:http://politics.people.com.cn/GB/1024/index2.html<br />
|
|
|
+ 输入为 http://politics.people.com.cn/GB/1024/index 2 .html分别埴入输入框内
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ <!-- <p class="tips" v-show="!this.ruleForm.second_start">请输入第2页网址</p>
|
|
|
+ <p class="tips" v-show="!this.ruleForm.second_num">请输入第2页网址</p>
|
|
|
+ <p class="tips" v-show="!this.ruleForm.second_end">请输入第2页网址</p> -->
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <el-form-item label="起始代码:" prop="startCode" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.startCode" placeholder="请输入起始代码"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 起始代码为文章列表第一篇文章上面几行代码中一段代码<br />
|
|
|
+ 如<'div class="ej list box clear">,输入为 .ej list box clear 埴入输入框内<br />
|
|
|
+ 如<'ul class="ej list box clear">,输入为 .ej list box clearul 埴入输入框内
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="结束页数:" prop="endPage" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.endPage" placeholder="请输入结束页数"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="dialogText">
|
|
|
+ <el-form-item label="标题字符串:" prop="title" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.title" placeholder="请输入网站名称"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 如标题代码:<'h1 class='news_art'>红枣滞销喂羊 电商帮忙促销</'h1>,标题字符串为 .news_art 填入输入框内<br />
|
|
|
+ 如标题代码:<'h1 id='news at'>红枣滞销喂羊 电商帮忙促销</'h1>,标题字符串为 #news art 填入输入框内
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="内容字符串:" prop="content" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.content" placeholder="请输入标题字符串"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 如内容代码:<'h1 class='news box'>
|
|
|
+ <' /h1>,内容字符串为.news box 填入输入框内<br />
|
|
|
+ 如内容代码:<'h1 id='news_box'>
|
|
|
+ <' /h1>,内容字符串为 #news_box 填入输入框内
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="来源字符串:" prop="" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.source" placeholder="请输入来源字符串"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="作者字符串:" prop="" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.author" placeholder="请输入作者字符串"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="作者替换名称:" prop="authorName" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.authorName" placeholder="请输入作者替换名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="two" v-show="this.webType == 2">
|
|
|
+ <div class="dialogText">
|
|
|
+ <el-form-item label="任务规则名:" prop="ruleName" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.ruleName" placeholder="请输入任务规则名"></el-input>
|
|
|
+ <el-tooltip class="item" effect="dark" content="任务规则名,如中国农村网-时政要闻" placement="top-start">
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="请求网址:" prop="collect" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.collect" placeholder="请输入请求网址(请求URL)"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 请求网址:网络(Network)-名称(Name)找名称 - <br />
|
|
|
+ 找到请求网址(Request URL):https://www.ndcpa.gov.cn/queryList,该网址填入输入框。
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="接口参数:" prop="parameter" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.parameter" placeholder="请输入接口参数"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 接口参数:网络(Network)-名称(Name)找名称 - Payload<br />
|
|
|
+ current=1,pageSize:25,webSiteCode[]:jbkzzx,channelCode[]:c100008<br />
|
|
|
+ 填入为{"current"=1,"pageSize":25,"webSiteCode":"[jbkzzx]","channelCode":"[c100008]"},中间用","隔开。
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="列表开始标签:" prop="startLabel" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.startLabel" placeholder="请输入列表开始标签"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 如包含本网页内所有的数据(data)下含有本网页内所有新闻的数据标签(resut),输入为 [data][result] 填入输入框。
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="标题字符串:" prop="title" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.title" placeholder="请输入标题字符串"></el-input>
|
|
|
+ <el-tooltip class="item" effect="dark" content="如(标题)是title=“xXX应急演习”,输入为 [title]埴入输入框。"
|
|
|
+ placement="top-start">
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="内容字符串:" prop="content" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.content" placeholder="请输入内容字符串"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 如内容(content)下含有本网页内所有新闻的详细数据(content),输入为[content][content] 填入输入框。
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="来源字符串:" prop="" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.source" placeholder="请输入来源字符串"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 如(来源)是contentSource="XXX应急处置部门",输入为[contentSource]埴入输入框。
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否有作者:" prop="name" class="keywords">
|
|
|
+ <el-radio v-model="radio" label="true">是</el-radio>
|
|
|
+ <el-radio v-model="radio" label="false">否</el-radio>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="作者字符串:" prop="author" class="keywords" v-show="this.radio == 'true'">
|
|
|
+ <el-input v-model="ruleForm.author" placeholder="请输入作者字符串"></el-input>
|
|
|
+ <el-tooltip placement="top-start">
|
|
|
+ <div slot="content">
|
|
|
+ 如作者(author)是author=“张三”,输入为 [author] 埴入输入框。
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="作者替换名称:" prop="authorName" class="keywords" v-show="this.radio == 'false'">
|
|
|
+ <el-input v-model="ruleForm.authorName" placeholder="请输入作者替换名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="three" v-show="this.webType == 3">
|
|
|
+ <div class="dialogText">
|
|
|
+ <el-form-item label="任务规则名:" prop="ruleName" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.ruleName" placeholder="请输入任务规则名"></el-input>
|
|
|
+ <el-tooltip class="item" effect="dark" content="任务规则名,如中国农村网-时政要闻" placement="top-start">
|
|
|
+ <i class="el-icon-warning"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="自定义规则:" prop="name" class="keywords">
|
|
|
+ <el-input v-model="ruleForm.diy_rule" type="textarea" :rows="8" resize="none"
|
|
|
+ placeholder="">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="dialogBtn">
|
|
|
+ <button class="cancel" @click="saveForm">保存</button>
|
|
|
+ <button class="submit" @click="submitForm">确定</button>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+//表格标题
|
|
|
+import tableTitle from './components/tableTitle.vue';
|
|
|
+//引入公用样式
|
|
|
+import '@/styles/global.less';
|
|
|
+// 引入api
|
|
|
+import { addRule, getRule, updateRule, delRule, sendCrawler } from '@/api/crawler'
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ tableTitle,//表格标题
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ const validateCollect = (rule, value, callback) => {
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ }
|
|
|
+ else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入请求网址'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validateStartLabel = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入列表开始标签'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validateRuleName = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入任务规则名'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validateFirst_url = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入第1页网址'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validateStartCode = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入起始代码'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validateEndCode = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入结束页数'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validatTitle = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入标题字符串'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validatcontent = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入内容字符串'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validatsource = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入来源字符串'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validatauthor = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入作者字符串'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validatauthorName = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入作者替换名称'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validatparameter = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (/\s/.test(value)) {
|
|
|
+ callback(new Error('输入的文字包含空格,请删除空格'))
|
|
|
+ } else if (value.length == 0) {
|
|
|
+ callback(new Error('请输入接口参数'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validatsecondWeb = (rule, value, callback) => {
|
|
|
+ // const value = input.value;
|
|
|
+ if (value.length == 0) {
|
|
|
+ callback(new Error('请输入第2页网址'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ tableDivTitle: "任务规则列表", //表格标题
|
|
|
+ dialogTableVisible: false, //弹窗是否显示
|
|
|
+ dialogName: '设置采集规则', //弹窗名称
|
|
|
+ dialogBoo: 'add',//判断当前是添加还是编辑
|
|
|
+ searchRuleName: '', //任务规则名
|
|
|
+
|
|
|
+ // 建立网站页面传递的参数
|
|
|
+ webId: '',
|
|
|
+ webType: '',
|
|
|
+ webName: '',
|
|
|
+
|
|
|
+ disabled: '',
|
|
|
+
|
|
|
+ //分页相关数据
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ total: 40,
|
|
|
+
|
|
|
+ activeId: '',
|
|
|
+ value: '',
|
|
|
+ radio: 'true',
|
|
|
+ // 表格相关
|
|
|
+ tableData: [], //表格中的数据
|
|
|
+
|
|
|
+ ruleForm: {
|
|
|
+ ruleName: '', //任务规则名
|
|
|
+ first_url: '', //第1页网址 接口类的开始采集地址
|
|
|
+ collect: '',//接口类 采集地址
|
|
|
+ second_start: '', //第2页网址开头
|
|
|
+ second_num: '', //第2页代码页数
|
|
|
+ second_end: '', //第2页网址结束字符串
|
|
|
+ startCode: '', //起始代码
|
|
|
+ startLabel: '', //列表开始标签
|
|
|
+ endPage: '', //结束页数
|
|
|
+ title: '', //标题字符串
|
|
|
+ content: '', //内容字符串
|
|
|
+ source: '', // 来源字符串
|
|
|
+ author: '', // 作者字符串
|
|
|
+ authorName: '', // 作者替换名称
|
|
|
+ parameter: '', //接口类2 接口参数
|
|
|
+ diy_rule: '' //自定义类
|
|
|
+ },
|
|
|
+
|
|
|
+ rules: { //规则
|
|
|
+ collect: [{ required: true, trigger: 'blur', validator: validateCollect }],
|
|
|
+ startLabel: [{ required: true, trigger: 'blur', validator: validateStartLabel }],
|
|
|
+ ruleName: [{ required: true, trigger: 'blur', validator: validateRuleName }],
|
|
|
+ first_url: [{ required: true, trigger: 'blur', validator: validateFirst_url }],
|
|
|
+ secondWeb: [{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
+ // second_start:[{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
+ // second_num:[{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
+ // second_end:[{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
+ second_start:[{ required: true, trigger: 'blur', message: '请输入网址开头' }],
|
|
|
+ second_num:[{ required: true, trigger: 'blur', message: '请输入代码页数' }],
|
|
|
+ second_end:[{ required: true, trigger: 'blur', message: '请输入网址结束字符串' }],
|
|
|
+
|
|
|
+ startCode: [{ required: true, trigger: 'blur', validator: validateStartCode }],
|
|
|
+ endPage: [{ required: true, trigger: 'blur', validator: validateEndCode }],
|
|
|
+ title: [{ required: true, trigger: 'blur', validator: validatTitle }],
|
|
|
+ content: [{ required: true, trigger: 'blur', validator: validatcontent }],
|
|
|
+ source: [{ required: true, trigger: 'blur', validator: validatsource }],
|
|
|
+ author: [{ required: true, trigger: 'blur', validator: validatauthor }],
|
|
|
+ authorName: [{ required: true, trigger: 'blur', validator: validatauthorName }],
|
|
|
+ parameter: [{ required: true, trigger: 'blur', validator: validatparameter }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //1.列表和分页相关 start ------------------------------------------------------------>
|
|
|
+ //1.1 开始请求列表信息方法
|
|
|
+ getData() {
|
|
|
+ getRule({
|
|
|
+ web_id: this.webId,
|
|
|
+ pageSize: this.pageSize,
|
|
|
+ page: this.page,
|
|
|
+ }).then(data => {
|
|
|
+ console.log(data.data.rep);
|
|
|
+ this.tableData = data.data.rep
|
|
|
+ this.total = data.data.count
|
|
|
+
|
|
|
+ let ifRun = false;
|
|
|
+ let runButtonId = "";
|
|
|
+ for (let item of this.tableData) {
|
|
|
+ if (item.status == 1) {
|
|
|
+ ifRun = true;
|
|
|
+ runButtonId = item.id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ifRun == true) {
|
|
|
+ this.pdStatus(runButtonId)
|
|
|
+ }
|
|
|
+ if (ifRun == true) {
|
|
|
+ this.disabled = false
|
|
|
+ // this.pdStatus(runButtonId)
|
|
|
+ } else {
|
|
|
+ this.disabled = true
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //1.2 删除内容
|
|
|
+ deleteRow(id) {
|
|
|
+ this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ }).then(() => {
|
|
|
+ delRule({
|
|
|
+ rule_id: id
|
|
|
+ }).then(data => {
|
|
|
+ console.log(data);
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ });
|
|
|
+ this.getData()
|
|
|
+ })
|
|
|
+ console.log("当前删除:" + id)
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '已取消删除'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // // 1.3
|
|
|
+ // handleClose() {
|
|
|
+ // this.dialogTableVisible = true
|
|
|
+
|
|
|
+ // },
|
|
|
+ //1.4 列表内容分页
|
|
|
+ //直接跳转
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.page = val;
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ //1.5 点击分页
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.page = val;
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ // 1.6 搜索按钮
|
|
|
+ goSearch() {
|
|
|
+ getRule({
|
|
|
+ web_id: this.webId,
|
|
|
+ pageSize: this.pageSize,
|
|
|
+ page: this.page,
|
|
|
+ keyWord: this.searchRuleName,
|
|
|
+ type: this.webType,
|
|
|
+ }).then(data => {
|
|
|
+ this.tableData = data.data.rep
|
|
|
+ this.total = data.data.count
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //1.7 重置按钮
|
|
|
+ goReset() {
|
|
|
+ this.searchRuleName = ""
|
|
|
+ this.getData()
|
|
|
+ },
|
|
|
+ //列表和分页相关 end ------------------------------------------------------------>
|
|
|
+
|
|
|
+ //1.8 设置采集规则
|
|
|
+ addCrawlerRule() {
|
|
|
+ if (!this.webType) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '当前不可设置采集规则',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.webType) {
|
|
|
+ this.dialogTableVisible = true
|
|
|
+ this.ruleForm.ruleName = ''
|
|
|
+ this.ruleForm.first_url = ''
|
|
|
+ this.ruleForm.collect = ''
|
|
|
+ this.ruleForm.second_start = ''
|
|
|
+ this.ruleForm.second_num = ''
|
|
|
+ this.ruleForm.second_end = ''
|
|
|
+ this.ruleForm.startCode = ''
|
|
|
+ this.ruleForm.startLabel = ''
|
|
|
+ this.ruleForm.endPage = ''
|
|
|
+ this.ruleForm.title = ''
|
|
|
+ this.ruleForm.content = ''
|
|
|
+ this.ruleForm.source = ''
|
|
|
+ this.ruleForm.author = ''
|
|
|
+ this.ruleForm.authorName = ''
|
|
|
+ this.ruleForm.parameter = ''
|
|
|
+ this.ruleForm.diy_rule = ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //1.9 编辑采集规则
|
|
|
+ goEdit(id, val) {
|
|
|
+ console.log(id);
|
|
|
+ this.activeId = id
|
|
|
+ console.log(val);
|
|
|
+ if (!this.webType) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '当前不可修改采集规则',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ } else if (this.webType == 1) {
|
|
|
+ this.dialogBoo = "update"
|
|
|
+ this.dialogTableVisible = true
|
|
|
+ this.ruleForm.ruleName = val.name
|
|
|
+ this.ruleForm.first_url = val.first_url
|
|
|
+ this.ruleForm.collect = val.first_url
|
|
|
+ this.ruleForm.second_start = val.second_start
|
|
|
+ this.ruleForm.second_num = val.second_num
|
|
|
+ this.ruleForm.second_end = val.second_end
|
|
|
+ this.ruleForm.startCode = val.start
|
|
|
+ this.ruleForm.startLabel = val.start
|
|
|
+ this.ruleForm.endPage = val.end_pagenum
|
|
|
+ this.ruleForm.title = val.title
|
|
|
+ this.ruleForm.content = val.content
|
|
|
+ this.ruleForm.source = val.source
|
|
|
+ this.ruleForm.author = val.writer_class
|
|
|
+ this.ruleForm.authorName = val.writer
|
|
|
+ this.ruleForm.parameter = val.parameter
|
|
|
+ this.ruleForm.diy_rule = val.diy_rule
|
|
|
+
|
|
|
+ } else if (this.webType == 2) {
|
|
|
+ this.dialogBoo = "update"
|
|
|
+ this.dialogTableVisible = true
|
|
|
+ this.ruleForm.ruleName = val.name
|
|
|
+ this.ruleForm.first_url = val.first_url
|
|
|
+ this.ruleForm.collect = val.first_url
|
|
|
+ this.ruleForm.second_start = val.second_start
|
|
|
+ this.ruleForm.second_num = val.second_num
|
|
|
+ this.ruleForm.second_end = val.second_end
|
|
|
+ this.ruleForm.startCode = val.start
|
|
|
+ this.ruleForm.startLabel = val.start
|
|
|
+ this.ruleForm.endPage = val.end_pagenum
|
|
|
+ this.ruleForm.title = val.title
|
|
|
+ this.ruleForm.content = val.content
|
|
|
+ this.ruleForm.source = val.source
|
|
|
+ this.ruleForm.parameter = val.parameter
|
|
|
+ this.ruleForm.diy_rule = val.diy_rule
|
|
|
+ if (this.radio == 'true') {
|
|
|
+ this.ruleForm.authorName = ''
|
|
|
+ this.ruleForm.author = val.writer_class
|
|
|
+ }
|
|
|
+ if (this.radio == 'false') {
|
|
|
+ this.ruleForm.author = ''
|
|
|
+ this.ruleForm.authorName = val.writer
|
|
|
+ }
|
|
|
+ } else if (this.webType == 3) {
|
|
|
+ this.dialogBoo = "update"
|
|
|
+ this.dialogTableVisible = true
|
|
|
+ this.ruleForm.ruleName = val.name
|
|
|
+ this.ruleForm.diy_rule=val.diy_rule
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ //采集
|
|
|
+ goCollect(id, status) {
|
|
|
+ for (let item of this.tableData) {
|
|
|
+ if (item.id == id) {
|
|
|
+ item.status = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sendCrawler({
|
|
|
+ id: id
|
|
|
+ }).then(data => {
|
|
|
+ console.log(data);
|
|
|
+ this.$message({
|
|
|
+ message: '采集中',
|
|
|
+ type: 'success',
|
|
|
+ iconClass: 'el-icon-refresh'
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //修改按钮状态
|
|
|
+ pdStatus(id) {
|
|
|
+ console.log(id)
|
|
|
+ for (let item of this.tableData) {
|
|
|
+ if (item.id == id) {
|
|
|
+ item.status = 1
|
|
|
+ } else {
|
|
|
+ item.status = 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(this.tableData)
|
|
|
+ },
|
|
|
+ toast() {
|
|
|
+ this.$message({
|
|
|
+ message: '一次只能采集一个任务规则',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 弹出层相关方法
|
|
|
+ // 提交表单
|
|
|
+ submitForm() {
|
|
|
+ //添加
|
|
|
+ if (this.dialogBoo == 'add') {
|
|
|
+ if (this.webType == 1) {
|
|
|
+ if (this.ruleForm.author == "") {
|
|
|
+ addRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ web_id: this.webId,
|
|
|
+ type: this.webType,
|
|
|
+ first_url: this.ruleForm.first_url,//规则型1:第1页网址 接口型2:开始采集地址
|
|
|
+ second_start: this.ruleForm.second_start,//规则型1:第2页网址开头
|
|
|
+ second_num: this.ruleForm.second_num,//规则型1:第2页代码页数
|
|
|
+ second_end: this.ruleForm.second_end,//规则型1:第2页网址结束字符串
|
|
|
+ start: this.ruleForm.startCode, //规则型1:列表标签类名 接口型2:列表标签
|
|
|
+ title: this.ruleForm.title, //规则型1:标题标签类名 接口型2:标题标签
|
|
|
+ content: this.ruleForm.content,//规则型1:内容标签类名 接口型2:内容标签
|
|
|
+ source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
+ // writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
+ writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ end_pagenum: this.ruleForm.endPage//规则型1:列表页结束页码
|
|
|
+ }).then(data => {
|
|
|
+ this.getData()
|
|
|
+ console.log(data);
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '添加成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ addRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ web_id: this.webId,
|
|
|
+ type: this.webType,
|
|
|
+ first_url: this.ruleForm.first_url,//规则型1:第1页网址 接口型2:开始采集地址
|
|
|
+ second_start: this.ruleForm.second_start,//规则型1:第2页网址开头
|
|
|
+ second_num: this.ruleForm.second_num,//规则型1:第2页代码页数
|
|
|
+ second_end: this.ruleForm.second_end,//规则型1:第2页网址结束字符串
|
|
|
+ start: this.ruleForm.startCode, //规则型1:列表标签类名 接口型2:列表标签
|
|
|
+ title: this.ruleForm.title, //规则型1:标题标签类名 接口型2:标题标签
|
|
|
+ content: this.ruleForm.content,//规则型1:内容标签类名 接口型2:内容标签
|
|
|
+ source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
+ writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
+ writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ end_pagenum: this.ruleForm.endPage//规则型1:列表页结束页码
|
|
|
+ }).then(data => {
|
|
|
+ this.getData()
|
|
|
+ console.log(data);
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '添加成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (this.webType == 2 && this.radio == 'true') {
|
|
|
+ addRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ web_id: this.webId,
|
|
|
+ type: this.webType,
|
|
|
+ first_url: this.ruleForm.collect,//规则型1:第1页网址 接口型2:开始采集地址
|
|
|
+ parameter: this.ruleForm.parameter,//接口型2:接口参数
|
|
|
+ start: this.ruleForm.startLabel, //规则型1:列表标签类名 接口型2:列表标签
|
|
|
+ title: this.ruleForm.title, //规则型1:标题标签类名 接口型2:标题标签
|
|
|
+ content: this.ruleForm.content,//规则型1:内容标签类名 接口型2:内容标签
|
|
|
+ source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
+ writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
+ // writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ }).then(data => {
|
|
|
+ this.getData()
|
|
|
+ console.log(data);
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '添加成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.ruleForm.authorName = ''
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ } else if (this.webType == 2 && this.radio == 'false') {
|
|
|
+ addRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ web_id: this.webId,
|
|
|
+ type: this.webType,
|
|
|
+ first_url: this.ruleForm.collect,//规则型1:第1页网址 接口型2:开始采集地址
|
|
|
+ parameter: this.ruleForm.parameter,//接口型2:接口参数
|
|
|
+ start: this.ruleForm.startLabel, //规则型1:列表标签类名 接口型2:列表标签
|
|
|
+ title: this.ruleForm.title, //规则型1:标题标签类名 接口型2:标题标签
|
|
|
+ content: this.ruleForm.content,//规则型1:内容标签类名 接口型2:内容标签
|
|
|
+ source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
+ // writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
+ writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ }).then(data => {
|
|
|
+ this.getData()
|
|
|
+ console.log(data);
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '添加成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.ruleForm.author = ''
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ } else if (this.webType == 3) {
|
|
|
+ addRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ web_id: this.webId,
|
|
|
+ type: this.webType,
|
|
|
+ diy_rule: this.ruleForm.diy_rule, //自定义3:规则
|
|
|
+ }).then(data => {
|
|
|
+ console.log(data);
|
|
|
+ this.getData()
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '添加成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //编辑
|
|
|
+ if (this.dialogBoo == 'update') {
|
|
|
+ if (this.webType == '') {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '当前不可设置采集规则',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.webType == 1) {
|
|
|
+ updateRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ id: this.activeId,
|
|
|
+ type: this.webType,
|
|
|
+ first_url: this.ruleForm.first_url,//规则型1:第1页网址 接口型2:开始采集地址
|
|
|
+ second_start: this.ruleForm.second_start,//规则型1:第2页网址开头
|
|
|
+ second_num: this.ruleForm.second_num,//规则型1:第2页代码页数
|
|
|
+ second_end: this.ruleForm.second_end,//规则型1:第2页网址结束字符串
|
|
|
+ start: this.ruleForm.startCode, //规则型1:列表标签类名 接口型2:列表标签
|
|
|
+ title: this.ruleForm.title, //规则型1:标题标签类名 接口型2:标题标签
|
|
|
+ content: this.ruleForm.content,//规则型1:内容标签类名 接口型2:内容标签
|
|
|
+ source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
+ writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
+ writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ end_pagenum: this.ruleForm.endPage//规则型1:列表页结束页码
|
|
|
+ }).then(data => {
|
|
|
+ this.getData()
|
|
|
+ console.log(data);
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '修改成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (this.webType == 2 && this.radio == 'true') {
|
|
|
+ updateRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ id: this.activeId,
|
|
|
+ type: this.webType,
|
|
|
+ first_url: this.ruleForm.collect,//规则型1:第1页网址 接口型2:开始采集地址
|
|
|
+ parameter: this.ruleForm.parameter,//接口型2:接口参数
|
|
|
+ start: this.ruleForm.startCode, //规则型1:列表标签类名 接口型2:列表标签
|
|
|
+ title: this.ruleForm.title, //规则型1:标题标签类名 接口型2:标题标签
|
|
|
+ content: this.ruleForm.content,//规则型1:内容标签类名 接口型2:内容标签
|
|
|
+ source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
+ writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
+ // writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ }).then(data => {
|
|
|
+ this.getData()
|
|
|
+ console.log(data);
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '修改成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.ruleForm.authorName = ""
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (this.webType == 2 && this.radio == 'false') {
|
|
|
+ this.ruleForm.author = ""
|
|
|
+ updateRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ id: this.activeId,
|
|
|
+ type: this.webType,
|
|
|
+ first_url: this.ruleForm.collect,//规则型1:第1页网址 接口型2:开始采集地址
|
|
|
+ parameter: this.ruleForm.parameter,//接口型2:接口参数
|
|
|
+ start: this.ruleForm.startCode, //规则型1:列表标签类名 接口型2:列表标签
|
|
|
+ title: this.ruleForm.title, //规则型1:标题标签类名 接口型2:标题标签
|
|
|
+ content: this.ruleForm.content,//规则型1:内容标签类名 接口型2:内容标签
|
|
|
+ source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
+ // writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
+ writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ }).then(data => {
|
|
|
+ this.getData()
|
|
|
+ console.log(data);
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '修改成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.ruleForm.author = ""
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (this.webType == 3) {
|
|
|
+ updateRule({
|
|
|
+ name: this.ruleForm.ruleName,
|
|
|
+ id: this.activeId,
|
|
|
+ type: this.webType,
|
|
|
+ diy_rule: this.ruleForm.diy_rule, //自定义3:规则
|
|
|
+ }).then(data => {
|
|
|
+ console.log(data);
|
|
|
+ this.getData()
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: '修改成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //保存
|
|
|
+ saveForm() {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ },
|
|
|
+ // 查看
|
|
|
+ goLook(id, val) {
|
|
|
+ console.log(id);
|
|
|
+ console.log(val);
|
|
|
+ console.log(val.name);
|
|
|
+
|
|
|
+ //跳转到规则列表页
|
|
|
+ this.$router.push({
|
|
|
+ path: '/webCrawlerList',
|
|
|
+ query: {
|
|
|
+ id: id,
|
|
|
+ source: val.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.webId = this.$route.query.id
|
|
|
+ this.webType = this.$route.query.type
|
|
|
+ this.webName = this.$route.query.name
|
|
|
+
|
|
|
+ //获取数据
|
|
|
+ this.getData()
|
|
|
+
|
|
|
+ },
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="less">
|
|
|
+.title {
|
|
|
+ margin: 30px 30px 20px 30px;
|
|
|
+ padding: 30px 30px 40px 30px;
|
|
|
+ background-color: #fff;
|
|
|
+ border-radius: 20px 20px 20px 20px;
|
|
|
+ border: 1px solid #E9EDF7;
|
|
|
+
|
|
|
+ .left {
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+
|
|
|
+ .right {
|
|
|
+ float: right;
|
|
|
+ }
|
|
|
+
|
|
|
+ .searchBox {
|
|
|
+ .searchTitle {
|
|
|
+ padding-bottom: 10px;
|
|
|
+ font-family: Microsoft YaHei, Microsoft YaHei;
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #999999;
|
|
|
+ line-height: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-select {
|
|
|
+ width: 300px;
|
|
|
+ display: inline-block;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .btnList {
|
|
|
+ float: right;
|
|
|
+ padding-top: 28px;
|
|
|
+
|
|
|
+ button {
|
|
|
+ width: 120px;
|
|
|
+ height: 38px;
|
|
|
+ border: none;
|
|
|
+ border-radius: 8px;
|
|
|
+ // padding: 0 30px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .search {
|
|
|
+ background-color: #5570f1;
|
|
|
+ color: #fff;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .reset {
|
|
|
+ font-family: Microsoft YaHei, Microsoft YaHei;
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 16px;
|
|
|
+ color: #333333;
|
|
|
+ background: #F5F7FB;
|
|
|
+ border-radius: 8px 8px 8px 8px;
|
|
|
+ border: 1px solid rgba(85, 112, 241, 0.11);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.layerBox {
|
|
|
+ padding: 30px 20px;
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ position: absolute;
|
|
|
+ top: 30px;
|
|
|
+ right: 20px;
|
|
|
+ height: 38px;
|
|
|
+ color: #fff;
|
|
|
+ background-color: #5570f1;
|
|
|
+ border: none;
|
|
|
+ border-radius: 8px;
|
|
|
+ padding: 8px 28px 9px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
+
|
|
|
+ .listBtnBox {
|
|
|
+ justify-content: left;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ .listDeleteBtn,
|
|
|
+ .listEditBtn,
|
|
|
+ .listLookBtn,
|
|
|
+ .loadingBtn,
|
|
|
+ .collector {
|
|
|
+ margin-left: 0px;
|
|
|
+ padding-left: 0px;
|
|
|
+ margin-right: 20px;
|
|
|
+ width: 76px;
|
|
|
+ height: 36px;
|
|
|
+ line-height: 36px;
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ .collectorIcon {
|
|
|
+ display: inline-block;
|
|
|
+ width: 20px;
|
|
|
+ height: 20px;
|
|
|
+ background: url("../../assets/advertise/Graph.png");
|
|
|
+ vertical-align: middle;
|
|
|
+ margin-right: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .collectorIcon1 {
|
|
|
+ position: absolute;
|
|
|
+ top: 12px;
|
|
|
+ left: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ .collector {
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 8px;
|
|
|
+ cursor: pointer;
|
|
|
+ color: #519C66;
|
|
|
+ background-color: rgba(81, 156, 102, 0.16);
|
|
|
+
|
|
|
+ >i {
|
|
|
+ padding-right: 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .loadingBtn {
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 8px;
|
|
|
+ cursor: pointer;
|
|
|
+ color: rgb(153, 153, 153);
|
|
|
+ background-color: rgba(153, 153, 153, 0.16);
|
|
|
+
|
|
|
+ >i {
|
|
|
+ padding-right: 0px;
|
|
|
+ }
|
|
|
+
|
|
|
+ >span {
|
|
|
+ padding-left: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .listLookBtn {
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 8px;
|
|
|
+ cursor: pointer;
|
|
|
+ color: #55b5f1;
|
|
|
+ background-color: rgba(85, 181, 241, 0.16);
|
|
|
+
|
|
|
+ >i {
|
|
|
+ padding-right: 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 弹出层内容
|
|
|
+.dialogText {
|
|
|
+ margin: 0 7px 30px 3px;
|
|
|
+ padding-top: 20px;
|
|
|
+ padding-bottom: 1px;
|
|
|
+ padding: 20px 60px 1px 20px;
|
|
|
+ background-color: #f5f7fb;
|
|
|
+
|
|
|
+ .pageTwo {
|
|
|
+ ::v-deep .el-col-6 {
|
|
|
+ width: 31%;
|
|
|
+ height: 32px;
|
|
|
+ margin-right: 24px;
|
|
|
+ }
|
|
|
+ .el_col_6_end{
|
|
|
+ margin-right: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .keywords {
|
|
|
+ ::v-deep .el-input {
|
|
|
+ position: relative;
|
|
|
+ font-size: 14px;
|
|
|
+ display: inline-block;
|
|
|
+ // width: 32%;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .lastInput {
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 资讯关键词 和 资讯描述 的 文字提示
|
|
|
+ .keywords,
|
|
|
+ .desc {
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ i {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: -15px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 弹出层按钮
|
|
|
+.dialogBtn {
|
|
|
+ text-align: center;
|
|
|
+ margin: 50px auto 20px;
|
|
|
+
|
|
|
+ button {
|
|
|
+ width: 184px;
|
|
|
+ padding: 16px;
|
|
|
+ font-family: Microsoft YaHei, Microsoft YaHei;
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 20px;
|
|
|
+ border: none;
|
|
|
+ border-radius: 12px 12px 12px 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 取消
|
|
|
+ .cancel {
|
|
|
+ color: #333333;
|
|
|
+ background-color: #f5f7fb;
|
|
|
+ border: 2px solid rgba(85, 112, 241, 0.11);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提交
|
|
|
+ .submit {
|
|
|
+ color: #fff;
|
|
|
+ background-color: #5570F1;
|
|
|
+ margin-left: 40px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep .el-form-item {
|
|
|
+ margin-bottom: 50px;
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep .el-select {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep .el-input--medium,
|
|
|
+::v-deep .el-form-item__label {
|
|
|
+ line-height: 36px;
|
|
|
+ // font-size: 16px;
|
|
|
+}
|
|
|
+</style>
|