|
|
@@ -1595,10 +1595,14 @@
|
|
|
|
|
|
let detailUrl = '';
|
|
|
let videoUrl = '';
|
|
|
- if(response.url().indexOf('/description/') > -1){ // 商品详情接口
|
|
|
+ if(response.url().indexOf('pc_item_getWareGraphic') > -1){ // 商品详情接口
|
|
|
detailUrl = response.url();
|
|
|
}
|
|
|
|
|
|
+ if(response.headers()['content-type'] == 'video/mp4'){
|
|
|
+ videoUrl = response.url();
|
|
|
+ }
|
|
|
+
|
|
|
if(response.url().indexOf('/tencent/video_v3') > -1){ // 商品视频接口
|
|
|
videoUrl = response.url();
|
|
|
}
|
|
|
@@ -1614,9 +1618,9 @@
|
|
|
let detailInfo = JSON.parse(data);
|
|
|
let regex = /\/\/img[0-9]+.360buyimg.com\S+.(jpg|jpeg|png|gif|avif|tif|tiff)/g;
|
|
|
let detailImgArr = [];
|
|
|
- if(detailInfo && detailInfo.content){
|
|
|
- if(detailInfo.content.match(regex)){
|
|
|
- detailImgArr = detailInfo.content.match(regex);
|
|
|
+ if(detailInfo && detailInfo.data.graphicContent){
|
|
|
+ if(detailInfo.data.graphicContent.match(regex)){
|
|
|
+ detailImgArr = detailInfo.data.graphicContent.match(regex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1658,31 +1662,7 @@
|
|
|
}
|
|
|
|
|
|
if(videoUrl && this.settingArr.indexOf('video') > -1){ // jd商品视频
|
|
|
- try {
|
|
|
- let data = await response.text();
|
|
|
- data = data.slice(0, -1).replace(/^jQuery[0-9]+\(/, '');
|
|
|
- let videoInfo = JSON.parse(data);
|
|
|
- let videoUrl = videoInfo.playUrl;
|
|
|
- jdImgInfo.video.push(videoUrl);
|
|
|
-
|
|
|
- let fileName = videoUrl.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(videoUrl, outputPath, urlInfo);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (error) {
|
|
|
- console.error('视频解析失败:', error);
|
|
|
- }
|
|
|
+ jdImgInfo.video.push(videoUrl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1732,10 +1712,18 @@
|
|
|
let outObj = {
|
|
|
mainImg: [],
|
|
|
skuImg: [],
|
|
|
- detailImg: []
|
|
|
+ detailImg: [],
|
|
|
+ video: []
|
|
|
};
|
|
|
//主图
|
|
|
- let arr1 = document.querySelectorAll('#spec-list img');
|
|
|
+ let arr1 = document.querySelectorAll('.thumbnails img[class*=image]');
|
|
|
+ if(arr1.length == 0){
|
|
|
+ arr1 = document.querySelectorAll('.thumbnails img');
|
|
|
+ }
|
|
|
+ if(arr1.length == 0){
|
|
|
+ arr1 = document.querySelectorAll('#spec-list img');
|
|
|
+ }
|
|
|
+
|
|
|
for(let i=0; i< arr1.length; i++){
|
|
|
let mainImgUrl = arr1[i].src;
|
|
|
let reg = /\/n[0-9]+\/jfs\//;
|
|
|
@@ -1785,6 +1773,14 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 视频
|
|
|
+ let arr4 = document.querySelectorAll('video');
|
|
|
+ for(let i=0; i< arr4.length; i++){
|
|
|
+ if(outObj.video.indexOf(arr4[i].src) == -1){
|
|
|
+ outObj.video.push(arr4[i].src);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return outObj;
|
|
|
}, authority, this.execNum);
|
|
|
|
|
|
@@ -1840,6 +1836,26 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //视频下载
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 详情图下载 --图书类目
|
|
|
if(this.settingArr.indexOf('detailImg') > -1 && jdImgInfo.detailImg.length == 0){
|
|
|
for(let j = 0; j < imgInfo.detailImg.length; j++){
|
|
|
@@ -2678,7 +2694,10 @@
|
|
|
let regex = /\.(.{3,4})_[0-9a-zA-z]+\.(.{3,4})_\.(.{3,4})/;
|
|
|
|
|
|
//主图
|
|
|
- let arr1 = document.querySelectorAll('img[class^=note-slider-img]');
|
|
|
+ let arr1 = document.querySelectorAll('.swiper-slide img');
|
|
|
+ if(arr1.length == 0){
|
|
|
+ arr1 = document.querySelectorAll('img[class^=note-slider-img]');
|
|
|
+ }
|
|
|
for(let i=0; i< arr1.length; i++){
|
|
|
let mainImgUrl = arr1[i].src;
|
|
|
let result = regex.exec(mainImgUrl);
|