Skip to content

Instantly share code, notes, and snippets.

@CovertCode
Created September 17, 2019 17:13
Show Gist options
  • Save CovertCode/94ee9e93fc3e8fa32508cae2d9bea26f to your computer and use it in GitHub Desktop.
Save CovertCode/94ee9e93fc3e8fa32508cae2d9bea26f to your computer and use it in GitHub Desktop.
px01 to px10
const puppeteer = require("puppeteer");
const VISIT_URL = "https://website.com/";
const botRun = {
initialize: async (proxyList, myDevice) => {
var proxyID = (await "--proxy-server=") + proxyList;
console.log(`Current Proxy: ${proxyList}`);
const args = [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-infobars",
"--window-position=0,0",
"--ignore-certifcate-errors",
"--ignore-certifcate-errors-spki-list",
proxyID
];
botRun.browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
headless: true,
args: args
});
botRun.page = await botRun.browser.newPage();
await botRun.page.emulate(myDevice);
try {
await botRun.page.goto(VISIT_URL, { waitUntil: "load", timeout: 0 });
await botRun.page.waitFor(20000);
await botRun.page.evaluate(_ => {
window.scrollBy(1, window.innerHeight);
});
await botRun.page.waitFor(2000);
await botRun.page.evaluate(_ => {
window.scrollBy(3, window.innerHeight);
});
await botRun.page.waitFor(2000);
await botRun.page.click('a[class="primary-btn"]');
await botRun.page.waitFor(30000);
await botRun.browser.close();
} catch {
console.log('Some sort of error')
await botRun.browser.close();
}
}
};
module.exports = botRun;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment