Puppeteer + Playwright
This commit is contained in:
@@ -23,6 +23,7 @@ class Interencheres extends Scraper {
|
||||
this._USER = ""
|
||||
this._PWD = ""
|
||||
this._PATH_SESSION_FILE = ".session/session_inter.json"
|
||||
this._BROWSER_TOOL = "puppeteerBrowser"
|
||||
}
|
||||
|
||||
getPictures = async ({ page, data}) => {
|
||||
@@ -148,21 +149,41 @@ class Interencheres extends Scraper {
|
||||
return LotList
|
||||
}
|
||||
|
||||
// ### Puppeteer
|
||||
// ###########################################################################
|
||||
|
||||
async CheckCookieDialog(page) {
|
||||
console.log("-- CheckCookieDialog --")
|
||||
return new Promise(async (resolve, reject) => {
|
||||
|
||||
const CookieButton = await page.$('//button[contains(@class, "cpm-cookies-bar-cta-refus") and contains(text(), "Refuser")]');
|
||||
//console.log(CookieButton)
|
||||
if (CookieButton && await CookieButton.isVisible()) {
|
||||
console.log("-- Click on CookieButton --")
|
||||
await CookieButton.click();
|
||||
}
|
||||
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
Live = async (browser) => {
|
||||
|
||||
console.log("Live "+this._Name+": "+this.Url)
|
||||
|
||||
|
||||
const page = await browser.newPage();
|
||||
|
||||
|
||||
let CheckAskStop = null;
|
||||
let Socket = null;
|
||||
const StopLive = async (params) => {
|
||||
clearInterval(CheckAskStop);
|
||||
Socket.off('Network.webSocketFrameReceived', listener);
|
||||
//Socket.off('Network.webSocketFrameReceived', listener);
|
||||
page.close()
|
||||
browser.close()
|
||||
}
|
||||
|
||||
const listener = async (params) => {
|
||||
|
||||
let payload = params.response.payloadData
|
||||
if(payload.length>1 && payload.substring(0, 2) == '42'){
|
||||
payload = JSON.parse(payload.substring(2))
|
||||
@@ -246,6 +267,7 @@ class Interencheres extends Scraper {
|
||||
|
||||
try{
|
||||
await page.goto(this.Url);
|
||||
|
||||
Socket = await page.target().createCDPSession();
|
||||
await Socket.send('Network.enable');
|
||||
await Socket.send('Page.enable');
|
||||
@@ -260,7 +282,7 @@ class Interencheres extends Scraper {
|
||||
StopLive()
|
||||
}
|
||||
})
|
||||
}, 10000); // 10000 milliseconds = 10 seconds
|
||||
}, 5000); // 10000 milliseconds = 5 seconds
|
||||
|
||||
}catch(e){
|
||||
console.log('Error : '+e)
|
||||
|
||||
@@ -299,7 +299,8 @@ class InterencheresData extends ScraperTools {
|
||||
const SaleTitleXPath = [
|
||||
'/html/body/div[1]/div/div/div/main/div/div/div/div/div/div[1]/div/div[1]/div[2]/h1/div/div/div/div/div',
|
||||
'/html/body/div[1]/div/div/div/main/div/div/div/div/div/div[1]/div/div/div/h1/div/div/div/div/div',
|
||||
'/html/body/div[1]/div/div/div/main/div/div/div/div/div/div[1]/div/div/div/div/h1/div/div/div/div/div'
|
||||
'/html/body/div[1]/div/div/div/main/div/div/div/div/div/div[1]/div/div/div/div/h1/div/div/div/div/div',
|
||||
'/html/body/div[1]/div/div/div[1]/main/div/div/div/div/div/div[1]/div/div/div/div/h1/div/div/div/div/div'
|
||||
]
|
||||
let SaleTitle = await this.getTextContent(SaleTitleXPath, page, 'SaleTitleXPath')
|
||||
return SaleTitle
|
||||
|
||||
Reference in New Issue
Block a user