|
@@ -1015,6 +1015,10 @@
|
|
|
|
|
|
let headless = true;
|
|
|
headless = this.initDevelop().headless;
|
|
|
+ let redSize = '';
|
|
|
+ if(this.menuIndex == '5'){
|
|
|
+ redSize = '--window-size=1280,800'; //给浏览器一个初始大小,在无头模式下,页面会自适用缩放
|
|
|
+ }
|
|
|
this[browserName] = await puppeteer.launch({
|
|
|
headless: headless,
|
|
|
executablePath: this.initPath(),
|
|
@@ -1023,7 +1027,8 @@
|
|
|
'--start-maximized',
|
|
|
'--no-sandbox',
|
|
|
'--disable-setuid-sandbox',
|
|
|
- '--disable-blink-features=AutomationControlled'
|
|
|
+ '--disable-blink-features=AutomationControlled',
|
|
|
+ redSize
|
|
|
]
|
|
|
});
|
|
|
|
|
@@ -1388,13 +1393,13 @@
|
|
|
}
|
|
|
this.loginBrowser = await puppeteer.launch({
|
|
|
executablePath: this.initPath(),
|
|
|
- args: ['--window-size=1280,800'],
|
|
|
userDataDir: this.initDataDir('jd'),
|
|
|
args: [
|
|
|
'--start-maximized',
|
|
|
'--no-sandbox',
|
|
|
'--disable-setuid-sandbox',
|
|
|
- '--disable-blink-features=AutomationControlled'
|
|
|
+ '--disable-blink-features=AutomationControlled',
|
|
|
+ '--window-size=1280,800'
|
|
|
]
|
|
|
});
|
|
|
const page = await this.loginBrowser.newPage();
|
|
@@ -2509,21 +2514,23 @@
|
|
|
|
|
|
// 定位元素
|
|
|
const handle = await page.$$('.pagination-media-container .pagination-item');
|
|
|
- if(handle.length > 0){ // 模拟鼠标拖动 将鼠标移动到元素的中心,然后开始拖动
|
|
|
+ if(handle.length > 0 && this.settingArr.indexOf('video') > -1){ // 模拟鼠标拖动 将鼠标移动到元素的中心,然后开始拖动
|
|
|
let handleLength = handle.length;
|
|
|
const box = await handle[0].boundingBox();
|
|
|
const boxEnd = await handle[handleLength - 1].boundingBox();
|
|
|
- const center = {
|
|
|
- x: box.x + box.width / 2,
|
|
|
- y: box.y + box.height / 2
|
|
|
- };
|
|
|
- const centerEnd = {
|
|
|
- x: boxEnd.x + boxEnd.width / 2,
|
|
|
- y: boxEnd.y + boxEnd.height / 2
|
|
|
- };
|
|
|
- await page.mouse.move(center.x, center.y);
|
|
|
- await page.mouse.down();
|
|
|
- await page.mouse.move(centerEnd.x, centerEnd.y, { steps: 50 }); // 新的位置,可以根据需要调整步骤数
|
|
|
+ if(box && boxEnd){ //确保元素可见,防止报错
|
|
|
+ const center = {
|
|
|
+ x: box.x + box.width / 2,
|
|
|
+ y: box.y + box.height / 2
|
|
|
+ };
|
|
|
+ const centerEnd = {
|
|
|
+ x: boxEnd.x + boxEnd.width / 2,
|
|
|
+ y: boxEnd.y + boxEnd.height / 2
|
|
|
+ };
|
|
|
+ await page.mouse.move(center.x, center.y);
|
|
|
+ await page.mouse.down();
|
|
|
+ await page.mouse.move(centerEnd.x, centerEnd.y, { steps: 50 }); // 新的位置,可以根据需要调整步骤数
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|