Hi there!
I am looking for a solution to automate my script to re-run in an infinite loop till the script is stopped, and also i am having difficulties to let the script continue after any error, it should just re-start the process.
At current, if all goes well it will run for some time till i get and error, then requires me to re-run the script manually evetime, here is the error i receive:
Here is my full code:
Any advice will be highly appreciated!
I am looking for a solution to automate my script to re-run in an infinite loop till the script is stopped, and also i am having difficulties to let the script continue after any error, it should just re-start the process.
At current, if all goes well it will run for some time till i get and error, then requires me to re-run the script manually evetime, here is the error i receive:
Code:
? new Error(`${response.errorText} at ${url}`)
^
Error: net::ERR_CONNECTION_CLOSED at https://*********.com
at navigate (file:///C:/Users/Omega/Desktop/GOLOGIN/node_modules/puppeteer-core/lib/esm/puppeteer/common/Frame.js:210:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Frame.goto (file:///C:/Users/Omega/Desktop/GOLOGIN/node_modules/puppeteer-core/lib/esm/puppeteer/common/Frame.js:180:21)
at async CDPPage.goto (file:///C:/Users/Omega/Desktop/GOLOGIN/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.js:436:16)
at async file:///C:/Users/Omega/Desktop/GOLOGIN/create.js:65:3
Here is my full code:
Code:
import puppeteer from 'puppeteer-core';
import GoLogin from './node_modules/gologin/src/gologin.js';
const delay = ms => new Promise(res => setTimeout(res, ms));
const { connect } = puppeteer;
function fingerprint(){
(async () => {
const GL = new GoLogin({
token: '********************',
});
// Generate Random Profile Username
let randomProfile = Math.floor(Math.random()*89999+1000000)
// next parameters are required for creating
const profile_id = await GL.create({
name: randomProfile,
os: 'win',
navigator: {
language: 'enUS',
userAgent: 'random', // get random user agent for selected os
resolution: '1920x1080',
platform: 'win',
},
proxyEnabled: true,
proxy: {
mode: 'http',
host: '********.com',
port: '10000',
username: '*******',
password: '*******',
autoProxyRegion: 'us',
},
});
console.log('profile id=', profile_id);
await GL.update({
id: profile_id,
name: randomProfile,
});
const profile = await GL.getProfile(profile_id);
console.log('new profile name=', profile.name);
// Goto site and wait, then delete profile
const { status, wsUrl } = await GL.start();
const browser = await connect({
browserWSEndpoint: wsUrl.toString(),
ignoreHTTPSErrors: true,
});
const page = await browser.newPage();
await page.goto('https://*************.com');
await delay(5000);
console.log(await page.content());
await delay(15000);
await browser.close();
await GL.stopLocal({ posting: false });
await GL.delete(profile_id);
console.log('Success');
//await GL.delete(profile_id);
})();
};
function run() {
setInterval(fingerprint, 25000);
};
run();
Any advice will be highly appreciated!