|
@@ -8,7 +8,7 @@
|
|
|
<span style="letter-spacing: 1px;">{{productName}}</span>
|
|
|
</p>
|
|
|
|
|
|
- <el-menu :default-openeds="['a', 'b']" :default-active="menuIndex" @select="setMenuIndex" active-text-color="#409EFF" background-color="#333744" text-color="#fff" style="margin-top: 10px;">
|
|
|
+ <el-menu :default-openeds="['a']" :default-active="menuIndex" @select="setMenuIndex" active-text-color="#409EFF" background-color="#333744" text-color="#fff" style="margin-top: 10px;">
|
|
|
<el-submenu index="a">
|
|
|
<template slot="title"><img src="../assets/image/m-download.png" class="m-image"/>图片下载</template>
|
|
|
<el-menu-item index="3">
|
|
@@ -23,11 +23,20 @@
|
|
|
<el-menu-item index="1">
|
|
|
<img src="../assets/image/m-alibaba.png" class="m-image"/><span slot="title">阿里巴巴</span>
|
|
|
</el-menu-item>
|
|
|
+ <el-menu-item index="6">
|
|
|
+ <img src="../assets/image/m-aliguoji.png" class="m-image"/><span slot="title">阿里国际</span>
|
|
|
+ </el-menu-item>
|
|
|
+ <el-menu-item index="7">
|
|
|
+ <img src="../assets/image/m-baidu.png" class="m-image"/><span slot="title">百度爱采购</span>
|
|
|
+ </el-menu-item>
|
|
|
+ <!-- <el-menu-item index="8">
|
|
|
+ <img src="../assets/image/m-amazon.png" class="m-image"/><span slot="title">亚马逊</span>
|
|
|
+ </el-menu-item> -->
|
|
|
<el-menu-item index="5">
|
|
|
<img src="../assets/image/m-hong.png" class="m-image"/><span slot="title">小红书</span>
|
|
|
</el-menu-item>
|
|
|
<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>
|
|
|
</el-menu-item>
|
|
|
</el-submenu>
|
|
|
|
|
@@ -56,7 +65,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>
|
|
|
|
|
|
- <el-main v-show="['1', '2', '3', '4', '5', '10'].indexOf(menuIndex) > -1" ref="el-main" style="background-color: #fafafa;">
|
|
|
+ <el-main v-show="['1', '2', '3', '4', '5', '6', '7', '8', '10'].indexOf(menuIndex) > -1" ref="el-main" style="background-color: #fafafa;">
|
|
|
<template>
|
|
|
<div class="content-top">
|
|
|
<div>
|
|
@@ -94,12 +103,18 @@
|
|
|
<span v-if="menuIndex == '3'">天猫 - </span>
|
|
|
<span v-if="menuIndex == '4'">淘宝 - </span>
|
|
|
<span v-if="menuIndex == '5'">小红书 - </span>
|
|
|
+ <span v-if="menuIndex == '6'">阿里国际 - </span>
|
|
|
+ <span v-if="menuIndex == '7'">百度爱采购 - </span>
|
|
|
+ <span v-if="menuIndex == '8'">亚马逊 - </span>
|
|
|
<span v-if="menuIndex == '10'">网页 - </span>
|
|
|
图片下载
|
|
|
</h3>
|
|
|
<el-link v-if="menuIndex == '5'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
|
|
|
仅支持win10及以上系统,浏览器请选择最新版本
|
|
|
</el-link>
|
|
|
+ <el-link v-if="menuIndex == '10'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
|
|
|
+ 非会员功能,仅提供测试试用
|
|
|
+ </el-link>
|
|
|
|
|
|
<!-- <el-link v-if="menuIndex == '3' || menuIndex == '4'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
|
|
|
(需登录{{menuIndex == '3' ? '天猫' : '淘宝'}}账号后才能下载)
|
|
@@ -128,12 +143,12 @@
|
|
|
<el-checkbox :value="true" style="opacity: 0.6; cursor: not-allowed;">图片</el-checkbox>
|
|
|
</div>
|
|
|
|
|
|
- <div v-if="['1', '2', '3', '4'].indexOf(menuIndex) > -1" style="padding-top: 10px;">
|
|
|
+ <div v-if="['1', '2', '3', '4', '6', '7', '8'].indexOf(menuIndex) > -1" style="padding-top: 10px;">
|
|
|
<label>下载类型:</label>
|
|
|
<el-checkbox-group :min="1" v-model="settingArr" style="display: inline-block;" @input="settingGroup">
|
|
|
<el-checkbox label="mainImg">主图</el-checkbox>
|
|
|
<el-checkbox label="detailImg">详情图</el-checkbox>
|
|
|
- <el-checkbox label="skuImg">SKU图</el-checkbox>
|
|
|
+ <el-checkbox label="skuImg" v-if="menuIndex != '7'">SKU图</el-checkbox>
|
|
|
<el-checkbox label="commentImg" v-if="menuIndex == '3' || menuIndex == '4'">评论图</el-checkbox>
|
|
|
<el-checkbox label="video">视频</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
@@ -234,8 +249,7 @@
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
<el-dialog title="添加链接" :visible.sync="addVisible" width="500px" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
|
|
|
<div>
|
|
|
<el-form label-position="right" label-width="80px" :rules="rules" :model="formData" ref="formData">
|
|
@@ -323,7 +337,8 @@
|
|
|
// import puppeteer from 'puppeteer'
|
|
|
import puppeteer from 'puppeteer-extra'
|
|
|
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
|
-
|
|
|
+ const listNameArr = ['alibaba','jd','tmall','tb','red','aliguoji','acaigou','amazon', '' ,'common'];
|
|
|
+
|
|
|
let separator = '';
|
|
|
if (os.platform == 'linux') {
|
|
|
separator = '/'
|
|
@@ -365,6 +380,9 @@
|
|
|
},
|
|
|
tabLoading: false,
|
|
|
alibabaList: [],
|
|
|
+ aliguojiList: [],
|
|
|
+ amazonList: [],
|
|
|
+ acaigouList: [],
|
|
|
jdList: [],
|
|
|
tbList: [],
|
|
|
tmallList: [],
|
|
@@ -380,7 +398,7 @@
|
|
|
commentImg: 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'],
|
|
|
|
|
|
fileList: [],
|
|
|
|
|
@@ -394,14 +412,18 @@
|
|
|
jdStatus: 1, // 1、未检测 2、已经登录 3、未登录
|
|
|
redStatus: 1, //同上
|
|
|
alibabaStatus: 1, //同上上
|
|
|
+ aliguojiStatus: 1, //同上上上
|
|
|
execLimit: 1,
|
|
|
execNum: 3, // 限制5张
|
|
|
|
|
|
/** 浏览器名称 **/
|
|
|
alibabaBrowser: null,
|
|
|
+ aliguojiBrowser: null,
|
|
|
+ amazonBrowser: null,
|
|
|
+ acaigouBrowser: null,
|
|
|
tbBrowser: null,
|
|
|
jdBrowser: null,
|
|
|
- otherBrowser: null,
|
|
|
+ commonBrowser: null,
|
|
|
redBrowser: null,
|
|
|
loginBrowser: null, // 登录用的浏览器实例
|
|
|
skipLogin: false,
|
|
@@ -409,28 +431,8 @@
|
|
|
},
|
|
|
computed: {
|
|
|
listStr: function(){
|
|
|
- let str = 'alibaba';
|
|
|
- switch(this.menuIndex){
|
|
|
- case '1':
|
|
|
- str = 'alibaba';
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- str = 'jd';
|
|
|
- break;
|
|
|
- case '3':
|
|
|
- str = 'tmall';
|
|
|
- break;
|
|
|
- case '4':
|
|
|
- str = 'tb';
|
|
|
- break;
|
|
|
- case '5':
|
|
|
- str = 'red';
|
|
|
- break;
|
|
|
- case '10':
|
|
|
- str = 'common';
|
|
|
- break;
|
|
|
- }
|
|
|
- return str;
|
|
|
+ let index = Number(this.menuIndex) - 1;
|
|
|
+ return listNameArr[index];
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
@@ -544,27 +546,9 @@
|
|
|
},
|
|
|
// 删除文件
|
|
|
delFile(rowIndex){
|
|
|
- let type = 'alibaba';
|
|
|
- switch(this.menuIndex){
|
|
|
- case '1':
|
|
|
- type = 'alibaba';
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- type = 'jd';
|
|
|
- break;
|
|
|
- case '3':
|
|
|
- type = 'tmall';
|
|
|
- break;
|
|
|
- case '4':
|
|
|
- type = 'tb';
|
|
|
- break;
|
|
|
- case '5':
|
|
|
- type = 'red';
|
|
|
- break;
|
|
|
- case '10':
|
|
|
- type = 'common';
|
|
|
- break;
|
|
|
- }
|
|
|
+ let index = Number(this.menuIndex) - 1;
|
|
|
+ let type = listNameArr[index];
|
|
|
+
|
|
|
this.$confirm('确认删除此行数据吗?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
@@ -580,26 +564,8 @@
|
|
|
},
|
|
|
// 清除列表
|
|
|
clearList() {
|
|
|
- switch(this.menuIndex){
|
|
|
- case '1':
|
|
|
- this.alibabaList = [];
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- this.jdList = [];
|
|
|
- break;
|
|
|
- case '3':
|
|
|
- this.tmallList = [];
|
|
|
- break;
|
|
|
- case '4':
|
|
|
- this.tbList = [];
|
|
|
- break;
|
|
|
- case '5':
|
|
|
- this.redList = [];
|
|
|
- break;
|
|
|
- case '10':
|
|
|
- this.commonList = [];
|
|
|
- break;
|
|
|
- }
|
|
|
+ let index = Number(this.menuIndex) - 1;
|
|
|
+ this[listNameArr[index]+'List'] = [];
|
|
|
},
|
|
|
// 提交表单
|
|
|
onSubmit(){
|
|
@@ -612,26 +578,8 @@
|
|
|
num: 0,
|
|
|
newPath: ''
|
|
|
}
|
|
|
- switch(this.menuIndex){
|
|
|
- case '1':
|
|
|
- this.alibabaList.push(info);
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- this.jdList.push(info);
|
|
|
- break;
|
|
|
- case '3':
|
|
|
- this.tmallList.push(info);
|
|
|
- break;
|
|
|
- case '4':
|
|
|
- this.tbList.push(info);
|
|
|
- break;
|
|
|
- case '5':
|
|
|
- this.redList.push(info);
|
|
|
- break;
|
|
|
- case '10':
|
|
|
- this.commonList.push(info);
|
|
|
- break;
|
|
|
- }
|
|
|
+ let index = Number(this.menuIndex) - 1;
|
|
|
+ this[listNameArr[index]+'List'].push(info);
|
|
|
this.$refs['formData'].resetFields();
|
|
|
this.addVisible = false;
|
|
|
} else {
|
|
@@ -680,26 +628,8 @@
|
|
|
num: 0,
|
|
|
newPath: ''
|
|
|
}
|
|
|
- switch(this.menuIndex){
|
|
|
- case '1':
|
|
|
- this.alibabaList.push(info);
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- this.jdList.push(info);
|
|
|
- break;
|
|
|
- case '3':
|
|
|
- this.tmallList.push(info);
|
|
|
- break;
|
|
|
- case '4':
|
|
|
- this.tbList.push(info);
|
|
|
- break;
|
|
|
- case '5':
|
|
|
- this.redList.push(info);
|
|
|
- break;
|
|
|
- case '10':
|
|
|
- this.commonList.push(info);
|
|
|
- break;
|
|
|
- }
|
|
|
+ let key = Number(this.menuIndex) - 1;
|
|
|
+ this[listNameArr[key]+'List'].push(info);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -729,35 +659,26 @@
|
|
|
name.splice(index, 1);
|
|
|
}
|
|
|
},
|
|
|
- // 清除缓存
|
|
|
+ // 清除缓存的后续操作
|
|
|
async clearCache(){
|
|
|
this.jdStatus = 3;
|
|
|
this.tbStatus = 3;
|
|
|
this.redStatus = 3;
|
|
|
+ this.alibabaStatus = 3;
|
|
|
+ this.aliguojiStatus = 3;
|
|
|
|
|
|
if(this.loginBrowser){
|
|
|
await this.loginBrowser.close();
|
|
|
this.loginBrowser = null;
|
|
|
}
|
|
|
- if(this.alibabaBrowser){
|
|
|
- await this.alibabaBrowser.close();
|
|
|
- this.alibabaBrowser = null;
|
|
|
- }
|
|
|
- if(this.tbBrowser){
|
|
|
- await this.tbBrowser.close();
|
|
|
- this.tbBrowser = null;
|
|
|
- }
|
|
|
- if(this.jdBrowser){
|
|
|
- await this.jdBrowser.close();
|
|
|
- this.jdBrowser = null;
|
|
|
- }
|
|
|
- if(this.redBrowser){
|
|
|
- await this.redBrowser.close();
|
|
|
- this.redBrowser = null;
|
|
|
- }
|
|
|
- if(this.otherBrowser){
|
|
|
- await this.otherBrowser.close();
|
|
|
- this.otherBrowser = null;
|
|
|
+
|
|
|
+ for(let i = 0; i < listNameArr.length; i++){
|
|
|
+ if(listNameArr[i]){
|
|
|
+ if(this[listNameArr[i]+'Browser']){
|
|
|
+ await this[listNameArr[i]+'Browser'].close();
|
|
|
+ this[listNameArr[i]+'Browser'] = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -809,27 +730,8 @@
|
|
|
fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
|
|
|
}
|
|
|
|
|
|
- let fileList = [];
|
|
|
- switch(this.menuIndex){
|
|
|
- case '1': // 阿里巴巴
|
|
|
- fileList = this.alibabaList;
|
|
|
- break;
|
|
|
- case '2': // 京东
|
|
|
- fileList = this.jdList;
|
|
|
- break;
|
|
|
- case '3': // 天猫
|
|
|
- fileList = this.tmallList;
|
|
|
- break;
|
|
|
- case '4': // 淘宝
|
|
|
- fileList = this.tbList;
|
|
|
- break;
|
|
|
- case '5': // 小红书
|
|
|
- fileList = this.redList;
|
|
|
- break;
|
|
|
- case '10': // 普通网址
|
|
|
- fileList = this.commonList;
|
|
|
- break;
|
|
|
- }
|
|
|
+ let index = Number(this.menuIndex) - 1;
|
|
|
+ let fileList = this[listNameArr[index]+'List'];
|
|
|
|
|
|
if(fileList.length > 0){
|
|
|
if (!authority && !flag) { // 非会员点击转换弹出提示框
|
|
@@ -918,30 +820,18 @@
|
|
|
|
|
|
let taskArr = [];
|
|
|
let task = "";
|
|
|
- let browserName = '';
|
|
|
let userDataDir = os.tmpdir() + separator + 'chrome-data-capture';
|
|
|
- switch(this.menuIndex){
|
|
|
- case '1': // 阿里巴巴
|
|
|
- browserName = 'alibaba';
|
|
|
- break;
|
|
|
- case '2': // 京东
|
|
|
- browserName = 'jd';
|
|
|
- userDataDir = os.tmpdir() + separator + 'chrome-data-capture-jd';
|
|
|
- break;
|
|
|
- case '3': // 天猫
|
|
|
- case '4': // 淘宝
|
|
|
- browserName = 'tb';
|
|
|
- break;
|
|
|
- case '5': // 小红书
|
|
|
- browserName = 'red';
|
|
|
- break;
|
|
|
- case '10': // 普通网址
|
|
|
- browserName = 'other';
|
|
|
- break;
|
|
|
+ if(this.menuIndex == '2'){
|
|
|
+ userDataDir = os.tmpdir() + separator + 'chrome-data-capture-jd';
|
|
|
}
|
|
|
// 运行不同平台的浏览器
|
|
|
puppeteer.use(StealthPlugin());
|
|
|
- this[browserName + 'Browser'] = await puppeteer.launch({
|
|
|
+ let browserName = listNameArr[index] + 'Browser';
|
|
|
+ if(index == '2'){ // 天猫和淘宝共用一个
|
|
|
+ browserName = 'tbBrowser';
|
|
|
+ }
|
|
|
+
|
|
|
+ this[browserName] = await puppeteer.launch({
|
|
|
executablePath: this.initPath(),
|
|
|
userDataDir: userDataDir,
|
|
|
args: [
|
|
@@ -969,8 +859,17 @@
|
|
|
case '5': // 小红书
|
|
|
task = this.redDownload(item, this.redBrowser);
|
|
|
break;
|
|
|
+ case '6': // 阿里国际
|
|
|
+ task = this.alibabaDownload(item, this.aliguojiBrowser);
|
|
|
+ break;
|
|
|
+ case '7': // 百度爱采购
|
|
|
+ task = this.alibabaDownload(item, this.acaigouBrowser);
|
|
|
+ break;
|
|
|
+ case '8': // 亚马逊
|
|
|
+ task = this.alibabaDownload(item, this.amazonBrowser);
|
|
|
+ break;
|
|
|
case '10': // 普通网址
|
|
|
- task = this.normalDownload(item, this.otherBrowser);
|
|
|
+ task = this.normalDownload(item, this.commonBrowser);
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -996,9 +895,9 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- if(this[browserName + 'Browser']){
|
|
|
- this[browserName + 'Browser'].close();
|
|
|
- this[browserName + 'Browser'] = null;
|
|
|
+ if(this[listNameArr[index] + 'Browser']){
|
|
|
+ this[listNameArr[index] + 'Browser'].close();
|
|
|
+ this[listNameArr[index] + 'Browser'] = null;
|
|
|
}
|
|
|
|
|
|
this.loading = false;
|
|
@@ -1011,7 +910,7 @@
|
|
|
},
|
|
|
|
|
|
// 10-普通网址下载
|
|
|
- async normalDownload(urlInfo, otherBrowser){
|
|
|
+ async normalDownload(urlInfo, commonBrowser){
|
|
|
let task = await new Promise((resolve,reject) =>{
|
|
|
(async () => {
|
|
|
try{
|
|
@@ -1020,7 +919,7 @@
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
// puppeteer.use(StealthPlugin());
|
|
|
- // const otherBrowser = await puppeteer.launch({
|
|
|
+ // const commonBrowser = await puppeteer.launch({
|
|
|
// executablePath: this.initPath(),
|
|
|
// userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
// args: [
|
|
@@ -1030,7 +929,7 @@
|
|
|
// '--disable-blink-features=AutomationControlled',
|
|
|
// ]
|
|
|
// });
|
|
|
- const page = await otherBrowser.newPage();
|
|
|
+ const page = await commonBrowser.newPage();
|
|
|
|
|
|
page.on('response', async(response) => {
|
|
|
// 检查响应的 MIME 类型是否以 'image/' 开头
|
|
@@ -1244,7 +1143,15 @@
|
|
|
if(start > num || start > 200){ // 防止页面过长,滚动200次自动停止
|
|
|
urlInfo.status = '3';
|
|
|
clearInterval(scrollInt);
|
|
|
- await this.alibabaScanImg(browser, page, urlInfo, authority);
|
|
|
+ if(this.menuIndex == '1'){ // 阿里巴巴
|
|
|
+ await this.alibabaScanImg(browser, page, urlInfo, authority);
|
|
|
+ }else if(this.menuIndex == '6'){ //阿里国际
|
|
|
+ await this.aliguojiScanImg(browser, page, urlInfo, authority);
|
|
|
+ }else if(this.menuIndex == '7'){ // 爱采购
|
|
|
+ await this.acaigouScanImg(browser, page, urlInfo, authority);
|
|
|
+ }else if(this.menuIndex == '8'){ // 亚马逊
|
|
|
+ await this.amazonScanImg(browser, page, urlInfo, authority);
|
|
|
+ }
|
|
|
this.loading = false;
|
|
|
urlInfo.status = '4';
|
|
|
resolve(true);
|
|
@@ -2404,6 +2311,498 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ /**************************阿里国际商品图片下载*******************************************************************************************/
|
|
|
+ // 6 - 阿里国际 - 扫描并下载图片
|
|
|
+ async aliguojiScanImg(browser, page, urlInfo, authority){
|
|
|
+ //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|
|
|
+ const imgInfo = await page.evaluate((authority, execNum) => {
|
|
|
+ let outObj = {
|
|
|
+ mainImg: [],
|
|
|
+ detailImg: [],
|
|
|
+ skuImg: [],
|
|
|
+ commentImg: [],
|
|
|
+ video: []
|
|
|
+ };
|
|
|
+
|
|
|
+ //主图
|
|
|
+ let arr1 = document.querySelectorAll('.module_productImage img[class*="-object-contain"]');
|
|
|
+ for(let i=0; i< arr1.length; i++){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.mainImg.push(arr1[i].src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.mainImg.push(arr1[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //sku图片
|
|
|
+ let arr2 = document.querySelectorAll('.module_sku img[class*="-object-contain"]');
|
|
|
+ for(let i=0; i< arr2.length; i++){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.skuImg.push(arr2[i].src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.skuImg.push(arr2[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //详情图片
|
|
|
+ let arr3 = document.querySelectorAll('#description-layout img');
|
|
|
+ // if(arr3.length == 0){
|
|
|
+ // if(document.getElementById('description') && document.getElementById('description').querySelector('.html-description')){
|
|
|
+ // arr3 = document.getElementById('description').querySelector('.html-description').shadowRoot.querySelectorAll('img');
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ for(let i=0; i< arr3.length; i++){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.detailImg.push(arr3[i].src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.detailImg.push(arr3[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 视频
|
|
|
+ let arr5 = document.querySelectorAll('#description-layout video');
|
|
|
+ for(let i=0; i< arr5.length; i++){
|
|
|
+ if(arr5[i].src && 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 fileName = imgInfo.mainImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '';
|
|
|
+ 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.mainImg[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // sku图片下载
|
|
|
+ if(this.settingArr.indexOf('skuImg') > -1){
|
|
|
+ for(let j = 0; j < imgInfo.skuImg.length; j++){
|
|
|
+ let fileName = imgInfo.skuImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '';
|
|
|
+ if(fileName.lastIndexOf('.') > -1){
|
|
|
+ suffix = fileName.substr(fileName.lastIndexOf('.'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\sku图');
|
|
|
+ }
|
|
|
+
|
|
|
+ let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
|
|
|
+ await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //详情图下载
|
|
|
+ if(this.settingArr.indexOf('detailImg') > -1){
|
|
|
+ for(let j = 0; j < imgInfo.detailImg.length; j++){
|
|
|
+ let fileName = imgInfo.detailImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '';
|
|
|
+ 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){
|
|
|
+ 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;
|
|
|
+ await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ await page.close(); // 关闭页面但不关闭浏览器
|
|
|
+ },
|
|
|
+ /*********************************************************************************************************************/
|
|
|
+
|
|
|
+ /**************************百度爱采购商品图片下载*******************************************************************************************/
|
|
|
+ // 7 - 百度爱采购 - 扫描并下载图片
|
|
|
+ async acaigouScanImg(browser, page, urlInfo, authority){
|
|
|
+ //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|
|
|
+ const imgInfo = await page.evaluate((authority, execNum) => {
|
|
|
+ let outObj = {
|
|
|
+ mainImg: [],
|
|
|
+ detailImg: [],
|
|
|
+ skuImg: [],
|
|
|
+ commentImg: [],
|
|
|
+ video: []
|
|
|
+ };
|
|
|
+
|
|
|
+ //主图
|
|
|
+ let arr1 = document.querySelectorAll('.album .img-container .img');
|
|
|
+ for(let i=0; i< arr1.length; i++){
|
|
|
+ let src = window.getComputedStyle(arr1[i]).backgroundImage.replace(/url\(["']?(.+?)["']?\)/i, '$1');
|
|
|
+ if(src && outObj.mainImg.indexOf(src) == -1){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.mainImg.push(src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.mainImg.push(src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //sku图片
|
|
|
+ // let arr2 = document.querySelectorAll('.module_sku img[class*="-object-contain"]');
|
|
|
+ // for(let i=0; i< arr2.length; i++){
|
|
|
+ // if(!authority && i < execNum){
|
|
|
+ // outObj.skuImg.push(arr2[i].src);
|
|
|
+ // }
|
|
|
+ // if(authority){
|
|
|
+ // outObj.skuImg.push(arr2[i].src);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //详情图片
|
|
|
+ let arr3 = document.querySelectorAll('.details .questionable-detail img');
|
|
|
+ for(let i=0; i< arr3.length; i++){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.detailImg.push(arr3[i].src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.detailImg.push(arr3[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 视频
|
|
|
+ let arr5 = document.querySelectorAll('.album video');
|
|
|
+ for(let i=0; i< arr5.length; i++){
|
|
|
+ if(arr5[i].src && 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 fileName = imgInfo.mainImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '.webp';
|
|
|
+ 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.mainImg[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // sku图片下载
|
|
|
+ if(this.settingArr.indexOf('skuImg') > -1){
|
|
|
+ for(let j = 0; j < imgInfo.skuImg.length; j++){
|
|
|
+ let fileName = imgInfo.skuImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '';
|
|
|
+ if(fileName.lastIndexOf('.') > -1){
|
|
|
+ suffix = fileName.substr(fileName.lastIndexOf('.'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\sku图');
|
|
|
+ }
|
|
|
+
|
|
|
+ let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
|
|
|
+ await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //详情图下载
|
|
|
+ if(this.settingArr.indexOf('detailImg') > -1){
|
|
|
+ for(let j = 0; j < imgInfo.detailImg.length; j++){
|
|
|
+ let fileName = imgInfo.detailImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '.webp';
|
|
|
+ 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){
|
|
|
+ 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;
|
|
|
+ await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ await page.close(); // 关闭页面但不关闭浏览器
|
|
|
+ },
|
|
|
+ /*********************************************************************************************************************/
|
|
|
+
|
|
|
+ /**************************亚马逊商品图片下载*******************************************************************************************/
|
|
|
+ // 8 - 亚马逊 - 扫描并下载图片
|
|
|
+ async amazonScanImg(browser, page, urlInfo, authority){
|
|
|
+ //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|
|
|
+ const imgInfo = await page.evaluate((authority, execNum) => {
|
|
|
+ let outObj = {
|
|
|
+ mainImg: [],
|
|
|
+ detailImg: [],
|
|
|
+ skuImg: [],
|
|
|
+ commentImg: [],
|
|
|
+ video: []
|
|
|
+ };
|
|
|
+
|
|
|
+ //主图
|
|
|
+ let arr1 = document.querySelectorAll('#leftCol img.a-dynamic-image');
|
|
|
+ for(let i=0; i< arr1.length; i++){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.mainImg.push(arr1[i].src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.mainImg.push(arr1[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //sku图片
|
|
|
+ let arr2 = document.querySelectorAll('.module_sku img[class*="-object-contain"]');
|
|
|
+ for(let i=0; i< arr2.length; i++){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.skuImg.push(arr2[i].src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.skuImg.push(arr2[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //详情图片
|
|
|
+ let arr3 = document.querySelectorAll('#description-layout img');
|
|
|
+ // if(arr3.length == 0){
|
|
|
+ // if(document.getElementById('description') && document.getElementById('description').querySelector('.html-description')){
|
|
|
+ // arr3 = document.getElementById('description').querySelector('.html-description').shadowRoot.querySelectorAll('img');
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ for(let i=0; i< arr3.length; i++){
|
|
|
+ if(!authority && i < execNum){
|
|
|
+ outObj.detailImg.push(arr3[i].src);
|
|
|
+ }
|
|
|
+ if(authority){
|
|
|
+ outObj.detailImg.push(arr3[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 视频
|
|
|
+ let arr5 = document.querySelectorAll('#description-layout video');
|
|
|
+ for(let i=0; i< arr5.length; i++){
|
|
|
+ if(arr5[i].src && 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 fileName = imgInfo.mainImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '';
|
|
|
+ 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.mainImg[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // sku图片下载
|
|
|
+ if(this.settingArr.indexOf('skuImg') > -1){
|
|
|
+ for(let j = 0; j < imgInfo.skuImg.length; j++){
|
|
|
+ let fileName = imgInfo.skuImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '';
|
|
|
+ if(fileName.lastIndexOf('.') > -1){
|
|
|
+ suffix = fileName.substr(fileName.lastIndexOf('.'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
|
|
|
+ fs.mkdirSync(urlInfo.newPath + '\\sku图');
|
|
|
+ }
|
|
|
+
|
|
|
+ let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
|
|
|
+ await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //详情图下载
|
|
|
+ if(this.settingArr.indexOf('detailImg') > -1){
|
|
|
+ for(let j = 0; j < imgInfo.detailImg.length; j++){
|
|
|
+ let fileName = imgInfo.detailImg[j].split('/').pop();
|
|
|
+ if(fileName){
|
|
|
+ let queryIndex = fileName.indexOf('?');
|
|
|
+ if (queryIndex !== -1) {
|
|
|
+ fileName = fileName.substr(0, queryIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ let num = Number(j) + 1;
|
|
|
+ let suffix = '';
|
|
|
+ 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){
|
|
|
+ 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;
|
|
|
+ await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ await page.close(); // 关闭页面但不关闭浏览器
|
|
|
+ },
|
|
|
+ /*********************************************************************************************************************/
|
|
|
+
|
|
|
+
|
|
|
//
|
|
|
downloadExample(){
|
|
|
let url = 'https://www.xingyousoft.com/soft/XYCapture/example.xlsx';
|