|
@@ -38,6 +38,12 @@
|
|
<el-menu-item index="5">
|
|
<el-menu-item index="5">
|
|
<img src="../assets/image/m-hong.png" class="m-image"/><span slot="title">小红书</span>
|
|
<img src="../assets/image/m-hong.png" class="m-image"/><span slot="title">小红书</span>
|
|
</el-menu-item>
|
|
</el-menu-item>
|
|
|
|
+ <el-menu-item index="11">
|
|
|
|
+ <img src="../assets/image/m-goofish.png" class="m-image"/><span slot="title">闲鱼</span>
|
|
|
|
+ </el-menu-item>
|
|
|
|
+ <el-menu-item index="12">
|
|
|
|
+ <img src="../assets/image/m-dy.png" class="m-image"/><span slot="title">抖店</span>
|
|
|
|
+ </el-menu-item>
|
|
|
|
|
|
<el-menu-item index="10">
|
|
<el-menu-item index="10">
|
|
<img src="../assets/image/m-chrome.png" class="m-image"/><span slot="title">其他(Beta)</span>
|
|
<img src="../assets/image/m-chrome.png" class="m-image"/><span slot="title">其他(Beta)</span>
|
|
@@ -69,7 +75,7 @@
|
|
|
|
|
|
<soft-img ref="imgRef" v-show="['2-1', '2-2', '2-3', '2-5'].indexOf(menuIndex) > -1" @open-vip="openVip" @check-authority="checkAuthority"></soft-img>
|
|
<soft-img ref="imgRef" v-show="['2-1', '2-2', '2-3', '2-5'].indexOf(menuIndex) > -1" @open-vip="openVip" @check-authority="checkAuthority"></soft-img>
|
|
|
|
|
|
- <el-main v-show="['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'].indexOf(menuIndex) > -1" ref="el-main" style="background-color: #fafafa;">
|
|
|
|
|
|
+ <el-main v-show="['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'].indexOf(menuIndex) > -1" ref="el-main" style="background-color: #fafafa;">
|
|
<template>
|
|
<template>
|
|
<div class="content-top">
|
|
<div class="content-top">
|
|
<div>
|
|
<div>
|
|
@@ -116,6 +122,8 @@
|
|
<span v-if="menuIndex == '8'">亚马逊 - </span>
|
|
<span v-if="menuIndex == '8'">亚马逊 - </span>
|
|
<span v-if="menuIndex == '9'">拼多多 - </span>
|
|
<span v-if="menuIndex == '9'">拼多多 - </span>
|
|
<span v-if="menuIndex == '10'">网页 - </span>
|
|
<span v-if="menuIndex == '10'">网页 - </span>
|
|
|
|
+ <span v-if="menuIndex == '11'">闲鱼 - </span>
|
|
|
|
+ <span v-if="menuIndex == '12'">抖店 - </span>
|
|
图片下载
|
|
图片下载
|
|
</h3>
|
|
</h3>
|
|
<el-link v-if="menuIndex == '5'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
|
|
<el-link v-if="menuIndex == '5'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
|
|
@@ -149,12 +157,12 @@
|
|
<el-checkbox :value="true" style="opacity: 0.6; cursor: not-allowed;">图片</el-checkbox>
|
|
<el-checkbox :value="true" style="opacity: 0.6; cursor: not-allowed;">图片</el-checkbox>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <div v-if="['1', '2', '3', '4', '6', '7', '8', '9'].indexOf(menuIndex) > -1" style="padding-top: 10px;">
|
|
|
|
|
|
+ <div v-if="['1', '2', '3', '4', '6', '7', '8', '9', '11', '12'].indexOf(menuIndex) > -1" style="padding-top: 10px;">
|
|
<label>下载类型:</label>
|
|
<label>下载类型:</label>
|
|
<el-checkbox-group :min="1" v-model="settingArr" style="display: inline-block;" @input="settingGroup">
|
|
<el-checkbox-group :min="1" v-model="settingArr" style="display: inline-block;" @input="settingGroup">
|
|
<el-checkbox label="mainImg">主图</el-checkbox>
|
|
<el-checkbox label="mainImg">主图</el-checkbox>
|
|
- <el-checkbox label="detailImg">详情图</el-checkbox>
|
|
|
|
- <el-checkbox label="skuImg" v-if="menuIndex != '7'">SKU图</el-checkbox>
|
|
|
|
|
|
+ <el-checkbox label="detailImg" v-if="menuIndex != '11'">详情图</el-checkbox>
|
|
|
|
+ <el-checkbox label="skuImg" v-if="menuIndex != '7' && menuIndex != '11' && menuIndex != '12'">SKU图</el-checkbox>
|
|
<el-checkbox label="commentImg" v-if="menuIndex == '3' || menuIndex == '4'">评论图</el-checkbox>
|
|
<el-checkbox label="commentImg" v-if="menuIndex == '3' || menuIndex == '4'">评论图</el-checkbox>
|
|
<el-checkbox label="video">主图视频</el-checkbox>
|
|
<el-checkbox label="video">主图视频</el-checkbox>
|
|
</el-checkbox-group>
|
|
</el-checkbox-group>
|
|
@@ -213,6 +221,7 @@
|
|
<el-button size="mini" type="warning" :loading="checkLoading" style="margin-left: 10px;" :disabled='pddStatus == 2' @click="checkPddLogin">检测登录状态</el-button>
|
|
<el-button size="mini" type="warning" :loading="checkLoading" style="margin-left: 10px;" :disabled='pddStatus == 2' @click="checkPddLogin">检测登录状态</el-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
+
|
|
</el-row>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -363,7 +372,7 @@
|
|
// import puppeteer from 'puppeteer'
|
|
// import puppeteer from 'puppeteer'
|
|
import puppeteer from 'puppeteer-extra'
|
|
import puppeteer from 'puppeteer-extra'
|
|
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
- const listNameArr = ['alibaba','jd','tmall','tb','red','aliguoji','acaigou','amazon', 'pdd' ,'common'];
|
|
|
|
|
|
+ const listNameArr = ['alibaba','jd','tmall','tb','red','aliguoji','acaigou','amazon', 'pdd' ,'common','goofish','dy'];
|
|
// const headless = true;
|
|
// const headless = true;
|
|
// const waitUntil = 'networkidle2';
|
|
// const waitUntil = 'networkidle2';
|
|
const { ipcRenderer } = require('electron');
|
|
const { ipcRenderer } = require('electron');
|
|
@@ -418,6 +427,8 @@
|
|
tmallList: [],
|
|
tmallList: [],
|
|
redList: [],
|
|
redList: [],
|
|
pddList: [],
|
|
pddList: [],
|
|
|
|
+ goofishList: [],
|
|
|
|
+ dyList: [],
|
|
commonList: [],
|
|
commonList: [],
|
|
productName: pjson.softInfo.softName,
|
|
productName: pjson.softInfo.softName,
|
|
imgUrl: this.$api.imgUrl,
|
|
imgUrl: this.$api.imgUrl,
|
|
@@ -430,7 +441,8 @@
|
|
video: false,
|
|
video: false,
|
|
},
|
|
},
|
|
exampleUrl: ['https://www.1688.com', 'https://www.jd.com', 'https://www.tmall.com', 'https://www.taobao.com', 'https://www.xiaohongshu.com',
|
|
exampleUrl: ['https://www.1688.com', 'https://www.jd.com', 'https://www.tmall.com', 'https://www.taobao.com', 'https://www.xiaohongshu.com',
|
|
- 'https://www.alibaba.com', 'https://b2b.baidu.com', 'https://www.amazon.com', 'https://mobile.yangkeduo.com/goods.html', 'https://www.example.com'],
|
|
|
|
|
|
+ 'https://www.alibaba.com', 'https://b2b.baidu.com', 'https://www.amazon.com', 'https://mobile.yangkeduo.com/goods.html', 'https://www.example.com',
|
|
|
|
+ 'https://www.goofish.com', 'https://v.douyin.com/xxxxxx/'],
|
|
|
|
|
|
fileList: [],
|
|
fileList: [],
|
|
|
|
|
|
@@ -459,6 +471,8 @@
|
|
commonBrowser: null,
|
|
commonBrowser: null,
|
|
redBrowser: null,
|
|
redBrowser: null,
|
|
pddBrowser: null,
|
|
pddBrowser: null,
|
|
|
|
+ goofishBrowser: null,
|
|
|
|
+ dyBrowser: null,
|
|
loginBrowser: null, // 登录用的浏览器实例
|
|
loginBrowser: null, // 登录用的浏览器实例
|
|
skipLogin: false,
|
|
skipLogin: false,
|
|
pauseFlag: true, //暂停中止标志
|
|
pauseFlag: true, //暂停中止标志
|
|
@@ -596,6 +610,15 @@
|
|
return 600;
|
|
return 600;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ // 任务下载间隔时间
|
|
|
|
+ initGap(){
|
|
|
|
+ let gap = this.$utils.getStorage('gap');
|
|
|
|
+ if(gap){
|
|
|
|
+ return Number(gap);
|
|
|
|
+ }else{
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
// 实时获取淘宝的开发者设置
|
|
// 实时获取淘宝的开发者设置
|
|
initDevelop(){
|
|
initDevelop(){
|
|
let develop = {
|
|
let develop = {
|
|
@@ -902,7 +925,15 @@
|
|
}
|
|
}
|
|
let authority = this.$refs.headerRef.authority.isAuthority;
|
|
let authority = this.$refs.headerRef.authority.isAuthority;
|
|
if (!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
|
|
if (!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
|
|
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
|
|
|
|
|
|
+ try{
|
|
|
|
+ fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
|
|
|
|
+ }catch(e){
|
|
|
|
+ this.$notify.error({
|
|
|
|
+ title: '保存目录不存在!- 1',
|
|
|
|
+ message: '请重新设置保存目录路径'
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
let index = Number(this.menuIndex) - 1;
|
|
let index = Number(this.menuIndex) - 1;
|
|
@@ -1070,6 +1101,12 @@
|
|
case '10': // 普通网址
|
|
case '10': // 普通网址
|
|
task = this.normalDownload(item, this.commonBrowser);
|
|
task = this.normalDownload(item, this.commonBrowser);
|
|
break;
|
|
break;
|
|
|
|
+ case '11': // 闲鱼
|
|
|
|
+ task = this.goofishDownload(item, this.goofishBrowser);
|
|
|
|
+ break;
|
|
|
|
+ case '12': // 抖店
|
|
|
|
+ task = this.dyDownload(item, this.dyBrowser);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
if(this.pauseFlag){ //暂停跳出循环
|
|
if(this.pauseFlag){ //暂停跳出循环
|
|
@@ -1112,6 +1149,16 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 通用的延迟函数
|
|
|
|
+ async delay() {
|
|
|
|
+ let s = this.initGap();
|
|
|
|
+ if(s > 0){
|
|
|
|
+ return new Promise(resolve => setTimeout(resolve, Number(s)*1000));
|
|
|
|
+ }else{
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
// 10-普通网址下载
|
|
// 10-普通网址下载
|
|
async normalDownload(urlInfo, commonBrowser){
|
|
async normalDownload(urlInfo, commonBrowser){
|
|
let task = await new Promise((resolve,reject) =>{
|
|
let task = await new Promise((resolve,reject) =>{
|
|
@@ -1224,6 +1271,7 @@
|
|
clearInterval(scrollInt);
|
|
clearInterval(scrollInt);
|
|
await page.close();
|
|
await page.close();
|
|
urlInfo.status = '4';
|
|
urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
resolve(true);
|
|
resolve(true);
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}
|
|
}
|
|
@@ -1373,6 +1421,7 @@
|
|
}
|
|
}
|
|
this.loading = false;
|
|
this.loading = false;
|
|
urlInfo.status = '4';
|
|
urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
resolve(true);
|
|
resolve(true);
|
|
}
|
|
}
|
|
}, scrollTime);
|
|
}, scrollTime);
|
|
@@ -1776,6 +1825,7 @@
|
|
/**end**/
|
|
/**end**/
|
|
await page.close();
|
|
await page.close();
|
|
urlInfo.status = '4';
|
|
urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
resolve(true);
|
|
resolve(true);
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}
|
|
}
|
|
@@ -2265,6 +2315,7 @@
|
|
|
|
|
|
await page.close();
|
|
await page.close();
|
|
urlInfo.status = '4';
|
|
urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
resolve(true);
|
|
resolve(true);
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}
|
|
}
|
|
@@ -2656,6 +2707,7 @@
|
|
|
|
|
|
await page.close();
|
|
await page.close();
|
|
urlInfo.status = '4';
|
|
urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
resolve(true);
|
|
resolve(true);
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}catch(e){
|
|
}catch(e){
|
|
@@ -3449,6 +3501,324 @@
|
|
|
|
|
|
await page.close();
|
|
await page.close();
|
|
urlInfo.status = '4';
|
|
urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
|
|
+ resolve(true);
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }catch(e){
|
|
|
|
+ urlInfo.status = '5';
|
|
|
|
+ reject(e);
|
|
|
|
+ this.showError(e);
|
|
|
|
+ }
|
|
|
|
+ })();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 10-闲鱼图片下载
|
|
|
|
+ async goofishDownload(urlInfo, pddBrowser){
|
|
|
|
+ let task = await new Promise((resolve,reject) =>{
|
|
|
|
+ (async () => {
|
|
|
|
+ try{
|
|
|
|
+ let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
|
+ let number = 0;
|
|
|
|
+ urlInfo.status = '2';
|
|
|
|
+ urlInfo.num = 0;
|
|
|
|
+ const page = await pddBrowser.newPage();
|
|
|
|
+ await page.goto(urlInfo.url, {waitUntil : 'networkidle2'});
|
|
|
|
+
|
|
|
|
+ if(urlInfo.title){
|
|
|
|
+ if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
|
|
|
|
+ urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
|
|
|
|
+ } else {
|
|
|
|
+ fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title);
|
|
|
|
+ urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ await this.getTitle(page, urlInfo); // 生成页面标题对应的文件夹
|
|
|
|
+ }
|
|
|
|
+ urlInfo.status = '3';
|
|
|
|
+
|
|
|
|
+ //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|
|
|
|
+ const imgInfo = await page.evaluate((authority, execNum) => {
|
|
|
|
+ let outObj = {
|
|
|
|
+ mainImg: [],
|
|
|
|
+ detailImg: [],
|
|
|
|
+ skuImg: [],
|
|
|
|
+ commentImg: [],
|
|
|
|
+ video: [],
|
|
|
|
+ skuName: []
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //主图
|
|
|
|
+ let arr1 = document.querySelectorAll('div[class^=carousel-container] img[class*=ant-image-img]')
|
|
|
|
+ for(let i=0; i< arr1.length; i++){
|
|
|
|
+ // if(i > 0 && i < arr1.length-1){ // 去掉首尾重复
|
|
|
|
+ let mainImgUrl = arr1[i].src || arr1[i].dataset.src;
|
|
|
|
+ if(outObj.mainImg.indexOf(mainImgUrl) == -1){
|
|
|
|
+ if(!authority && i < execNum){
|
|
|
|
+ outObj.mainImg.push(mainImgUrl);
|
|
|
|
+ }
|
|
|
|
+ if(authority){
|
|
|
|
+ outObj.mainImg.push(mainImgUrl);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 视频
|
|
|
|
+ let arr5 = document.querySelectorAll('video source');
|
|
|
|
+ if(arr5.length == 0){
|
|
|
|
+ arr5 = document.querySelectorAll('video');
|
|
|
|
+ }
|
|
|
|
+ for(let i=0; i< arr5.length; i++){
|
|
|
|
+ if(outObj.video.indexOf(arr5[i].src) == -1){
|
|
|
|
+ if(!authority && i < execNum){
|
|
|
|
+ outObj.video.push(arr5[i].src);
|
|
|
|
+ }
|
|
|
|
+ if(authority){
|
|
|
|
+ outObj.video.push(arr5[i].src);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return outObj;
|
|
|
|
+ }, authority, this.execNum);
|
|
|
|
+
|
|
|
|
+ // 主图下载
|
|
|
|
+ if(this.settingArr.indexOf('mainImg') > -1){
|
|
|
|
+ for(let j = 0; j < imgInfo.mainImg.length; j++){
|
|
|
|
+ let imgUrl = imgInfo.mainImg[j];
|
|
|
|
+ let queryIndex = imgInfo.mainImg[j].indexOf('?');
|
|
|
|
+ if (queryIndex !== -1) {
|
|
|
|
+ imgUrl = imgUrl.substr(0, queryIndex);
|
|
|
|
+ }
|
|
|
|
+ let fileName = imgUrl.split('/').pop();
|
|
|
|
+ let num = Number(j) + 1;
|
|
|
|
+ let suffix = '.jpg';
|
|
|
|
+ if(fileName.lastIndexOf('.') > -1){
|
|
|
|
+ suffix = fileName.substr(fileName.lastIndexOf('.'));
|
|
|
|
+ }
|
|
|
|
+ if(suffix == '.webp'){
|
|
|
|
+ suffix = '.jpg';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
|
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\主图');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
|
|
|
|
+ await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //视频下载
|
|
|
|
+ if(this.settingArr.indexOf('video') > -1){
|
|
|
|
+ for(let j = 0; j < imgInfo.video.length; j++){
|
|
|
|
+ let fileName = imgInfo.video[j].split('/').pop();
|
|
|
|
+ if(fileName){
|
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
|
+ if (queryIndex !== -1) {
|
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
|
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\视频');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let outputPath = urlInfo.newPath + '\\视频\\' + fileName + '.mp4';
|
|
|
|
+ await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await page.close();
|
|
|
|
+ urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
|
|
+ resolve(true);
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }catch(e){
|
|
|
|
+ urlInfo.status = '5';
|
|
|
|
+ reject(e);
|
|
|
|
+ this.showError(e);
|
|
|
|
+ }
|
|
|
|
+ })();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 12-抖店图片下载
|
|
|
|
+ async dyDownload(urlInfo, pddBrowser){
|
|
|
|
+ let task = await new Promise((resolve,reject) =>{
|
|
|
|
+ (async () => {
|
|
|
|
+ try{
|
|
|
|
+ let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
|
+ let number = 0;
|
|
|
|
+ urlInfo.status = '2';
|
|
|
|
+ urlInfo.num = 0;
|
|
|
|
+ const page = await pddBrowser.newPage();
|
|
|
|
+ await page.goto(urlInfo.url, {waitUntil : 'networkidle2'});
|
|
|
|
+
|
|
|
|
+ if(urlInfo.title){
|
|
|
|
+ if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
|
|
|
|
+ urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
|
|
|
|
+ } else {
|
|
|
|
+ fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title);
|
|
|
|
+ urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ // 获取商品标题
|
|
|
|
+ let titleHandle = await page.$$('div.title-info');
|
|
|
|
+ if(titleHandle && titleHandle.length > 0){
|
|
|
|
+ let titleValue = await page.$eval('div.title-info', el => el.innerText);
|
|
|
|
+ await this.getTitle(page, urlInfo, titleValue); // 生成页面标题对应的文件夹
|
|
|
|
+ }else{
|
|
|
|
+ await this.getTitle(page, urlInfo, '抖店商品-'+new Date().getTime()); // 生成页面标题对应的文件夹
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ urlInfo.status = '3';
|
|
|
|
+
|
|
|
|
+ // 被限制验证码拦截
|
|
|
|
+ let notSale = await page.$$('#captcha_container');
|
|
|
|
+ if(notSale && notSale.length > 0){
|
|
|
|
+ await page.close();
|
|
|
|
+ urlInfo.status = '6';
|
|
|
|
+ resolve(true);
|
|
|
|
+ this.loading = false;
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|
|
|
|
+ const imgInfo = await page.evaluate((authority, execNum) => {
|
|
|
|
+ let outObj = {
|
|
|
|
+ mainImg: [],
|
|
|
|
+ detailImg: [],
|
|
|
|
+ skuImg: [],
|
|
|
|
+ commentImg: [],
|
|
|
|
+ video: [],
|
|
|
|
+ skuName: []
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ let skuHandle = document.querySelector('img[class*=video__play-icon]');
|
|
|
|
+ if(skuHandle){
|
|
|
|
+ skuHandle.click({force: true});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //主图
|
|
|
|
+ let arr1 = document.querySelectorAll('div[class*=swiper-slide] div');
|
|
|
|
+ if(arr1.length == 0){
|
|
|
|
+ arr1 = document.querySelectorAll('div[class^=head-figure__media-view]');
|
|
|
|
+ }
|
|
|
|
+ for(let i=0; i< arr1.length; i++){
|
|
|
|
+ let mainImgUrl = window.getComputedStyle(arr1[i]).backgroundImage.replace(/url\(["']?(.+?)["']?\)/i, '$1');
|
|
|
|
+ if(outObj.mainImg.indexOf(mainImgUrl) == -1){
|
|
|
|
+ if(!authority && i < execNum){
|
|
|
|
+ outObj.mainImg.push(mainImgUrl);
|
|
|
|
+ }
|
|
|
|
+ if(authority){
|
|
|
|
+ outObj.mainImg.push(mainImgUrl);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //详情图
|
|
|
|
+ let arr3 = document.querySelectorAll('div[class=product-big-img-list] img');
|
|
|
|
+ if(arr3.length == 0){
|
|
|
|
+ arr3 = document.querySelectorAll('div[class=partial-detail-wrapper] img');
|
|
|
|
+ if(arr3.length == 0){
|
|
|
|
+ arr3 = document.querySelectorAll('img[class^=product-big-img-list]');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for(let i=0; i< arr3.length; i++){
|
|
|
|
+ let detailImgUrl = arr3[i].src || arr3[i].dataset.src;
|
|
|
|
+ if(!authority && i < execNum){
|
|
|
|
+ outObj.detailImg.push(detailImgUrl);
|
|
|
|
+ }
|
|
|
|
+ if(authority){
|
|
|
|
+ outObj.detailImg.push(detailImgUrl);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 视频
|
|
|
|
+ let arr5 = document.querySelectorAll('video');
|
|
|
|
+ for(let i=0; i< arr5.length; i++){
|
|
|
|
+ if(outObj.video.indexOf(arr5[i].src) == -1){
|
|
|
|
+ if(!authority && i < execNum){
|
|
|
|
+ outObj.video.push(arr5[i].src);
|
|
|
|
+ }
|
|
|
|
+ if(authority){
|
|
|
|
+ outObj.video.push(arr5[i].src);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return outObj;
|
|
|
|
+ }, authority, this.execNum);
|
|
|
|
+
|
|
|
|
+ // 主图下载
|
|
|
|
+ if(this.settingArr.indexOf('mainImg') > -1){
|
|
|
|
+ for(let j = 0; j < imgInfo.mainImg.length; j++){
|
|
|
|
+ let imgUrl = imgInfo.mainImg[j];
|
|
|
|
+ let queryIndex = imgInfo.mainImg[j].indexOf('?');
|
|
|
|
+ if (queryIndex !== -1) {
|
|
|
|
+ imgUrl = imgUrl.substr(0, queryIndex);
|
|
|
|
+ }
|
|
|
|
+ let fileName = imgUrl.split('/').pop();
|
|
|
|
+ let num = Number(j) + 1;
|
|
|
|
+ let suffix = '.jpg';
|
|
|
|
+ if(fileName.lastIndexOf('.') > -1){
|
|
|
|
+ suffix = fileName.substr(fileName.lastIndexOf('.'));
|
|
|
|
+ }
|
|
|
|
+ if(suffix == '.webp'){
|
|
|
|
+ suffix = '.jpg';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
|
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\主图');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
|
|
|
|
+ await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //详情图下载
|
|
|
|
+ if(this.settingArr.indexOf('detailImg') > -1){
|
|
|
|
+ for(let j = 0; j < imgInfo.detailImg.length; j++){
|
|
|
|
+ let imgUrl = imgInfo.detailImg[j];
|
|
|
|
+ let queryIndex = imgInfo.detailImg[j].indexOf('?');
|
|
|
|
+ if (queryIndex !== -1) {
|
|
|
|
+ imgUrl = imgUrl.substr(0, queryIndex);
|
|
|
|
+ }
|
|
|
|
+ let fileName = imgUrl.split('/').pop();
|
|
|
|
+ let num = Number(j) + 1;
|
|
|
|
+ let suffix = '.jpg';
|
|
|
|
+ if(fileName.lastIndexOf('.') > -1){
|
|
|
|
+ suffix = fileName.substr(fileName.lastIndexOf('.'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
|
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\详情图');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let outputPath = urlInfo.newPath + '\\详情图\\详情图' + num + suffix;
|
|
|
|
+ await this.downloadImage(imgInfo.detailImg[j], outputPath, urlInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //视频下载
|
|
|
|
+ if(this.settingArr.indexOf('video') > -1){
|
|
|
|
+ for(let j = 0; j < imgInfo.video.length; j++){
|
|
|
|
+ let fileName = imgInfo.video[j].split('/').pop();
|
|
|
|
+ if(fileName){
|
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
|
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\视频');
|
|
|
|
+ }
|
|
|
|
+ let outputPath = urlInfo.newPath + '\\视频\\视频.mp4' ;
|
|
|
|
+ await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await page.close();
|
|
|
|
+ urlInfo.status = '4';
|
|
|
|
+ await this.delay();
|
|
resolve(true);
|
|
resolve(true);
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}catch(e){
|
|
}catch(e){
|
|
@@ -3850,4 +4220,8 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ .el-menu-item{
|
|
|
|
+ height: 45px !important;
|
|
|
|
+ line-height: 45px !important;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|