Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
console.log('start', scriptName)
const browser = await puppeteer.launch({
headless: false,
executablePath: `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` // MacOS
})
const page = await browser.newPage()
await page.setViewport({ width: 800, height: 600 })
await page.goto('https://bot.sannysoft.com/')
await page.waitFor(5000)
await page.screenshot({ path: screenshotPath, fullPage: true })
await browser.close()
console.log('end', screenshotPath)
}
main()
const path = require('path')
const scriptName = path.basename(__filename)
const screenshotPath = path.join(__dirname, '_results', `${scriptName}.png`)
const puppeteer = require('puppeteer-extra')
const pluginStealth = require('puppeteer-extra-plugin-stealth')()
puppeteer.use(pluginStealth)
async function main() {
console.log('start', scriptName)
const browser = await puppeteer.launch({
headless: true,
executablePath: `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` // MacOS
})
const page = await browser.newPage()
await page.setViewport({ width: 800, height: 600 })
await page.goto('https://bot.sannysoft.com/')
await page.waitFor(5000)
await page.screenshot({ path: screenshotPath, fullPage: true })
await browser.close()
console.log('end', screenshotPath)
const path = require('path')
const scriptName = path.basename(__filename)
const screenshotPath = path.join(__dirname, '_results', `${scriptName}.png`)
const puppeteer = require('puppeteer-extra')
const pluginStealth = require('puppeteer-extra-plugin-stealth')()
puppeteer.use(pluginStealth)
async function main() {
console.log('start', scriptName)
const browser = await puppeteer.launch({
headless: false,
executablePath: `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` // MacOS
})
const page = await browser.newPage()
await page.setViewport({ width: 800, height: 600 })
await page.goto('https://bot.sannysoft.com/')
await page.waitFor(5000)
await page.screenshot({ path: screenshotPath, fullPage: true })
await browser.close()
console.log('end', screenshotPath)
async init() {
this.browserInstance = await puppeteer.launch({
headless: this.options.headless,
// args: ['--deterministic-fetch'],
defaultViewport: {
width: 1600,
height: 900
}
}).catch((err) => {throw Error(err)});
}
const puppeteer = require('puppeteer-extra');
const pluginStealth = require("puppeteer-extra-plugin-stealth");
puppeteer.use(pluginStealth());
module.exports = class Browser {
constructor (args) {
this.options = {};
this.options.headless = (Object.keys(args).indexOf('debug') === -1);
}
async init() {
this.browserInstance = await puppeteer.launch({
headless: this.options.headless,
// args: ['--deterministic-fetch'],
defaultViewport: {
width: 1600,
height: 900
}
}).catch((err) => {throw Error(err)});
//
// const puppeteer = require('puppeteer-extra')
// puppeteer.use(require('puppeteer-extra-plugin-block-resources')({
// blockedTypes: new Set(['image', 'stylesheet'])
// }))
// ;(async () => {
// const browser = await puppeteer.launch({ headless: false })
// const page = await browser.newPage()
// await page.goto('http://www.msn.com/', {waitUntil: 'domcontentloaded'})
// console.log('all done')
// })()
const puppeteer = require('puppeteer-extra')
const blockResourcesPlugin = require('puppeteer-extra-plugin-block-resources')()
puppeteer.use(blockResourcesPlugin)
;(async () => {
const browser = await puppeteer.launch({ headless: false })
const page = await browser.newPage()
blockResourcesPlugin.blockedTypes.add('image')
await page.goto('http://www.msn.com/', { waitUntil: 'domcontentloaded' })
blockResourcesPlugin.blockedTypes.add('stylesheet')
blockResourcesPlugin.blockedTypes.add('other') // e.g. favicon
await page.goto('http://news.ycombinator.com', {
waitUntil: 'domcontentloaded'
})
blockResourcesPlugin.blockedTypes.delete('stylesheet')
blockResourcesPlugin.blockedTypes.delete('other')
blockResourcesPlugin.blockedTypes.add('media')
const toCSV = require('./lib/toCSV');
const toLedger = require('./lib/toLedger');
const temp = require('temp').track();
const fs = require('fs-extra');
const writeYaml = util.promisify(require('write-yaml'));
const collateLedgerData = require('./lib/collateLedgerData');
const ledgerBalanceReport = require('./lib/ledgerBalanceReport');
const jsYaml = require('js-yaml');
const parseConfiguration = require('./lib/parseConfiguration');
// Initialize puppeteer with a few stealthy plugins
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
const UserAgentPlugin = require('puppeteer-extra-plugin-anonymize-ua');
puppeteer.use(UserAgentPlugin({makeWindows: false}));
program
.version('0.3.0')
.option('-c, --config ', 'Ledger Reconciler config file')
.option('--silent', 'Suppress all output except warnings & errors')
.option('--debug', 'Print out debug output')
.option('--dry-run', 'Perform a dry run - scrape transactions for all plugins but do not update anything')
.parse(process.argv);
process.on('unhandledRejection', err => {
logger.error(JSON.stringify(err));
logger.error(err.stack);
process.exit(1);
});
// Initiate the logger instance
if (this.proxy != null) {
args = [
'--no-sandbox',
`--window-size=${config.windowWidth},${config.windowHeight}`,
`--proxy-server=${this.proxy}`
];
} else {
args = [
'--no-sandbox',
`--window-size=${config.windowWidth},${config.windowHeight}`,
];
}
// Launch the browser
this.browser = await puppeteer.launch({
args,
headless: config.headless,
ignoreHTTPSErrors: true,
userDataDir: path.resolve('saves', 'chrome_' + this.instance)
});
// Add google cookies to browser if provided
if (Object.keys(GOOGLE_COOKIES).length != 0) {
const cookiePage = await this.browser.newPage();
cookiePage.setDefaultNavigationTimeout(60000);
await cookiePage.goto('http://www.google.com/404');
for (let cookie of GOOGLE_COOKIES) {
await cookiePage.setCookie({
name: cookie.name,
// puppeteer-extra is a drop-in replacement for puppeteer,
// it augments the installed puppeteer with plugin functionality
const puppeteer = require("puppeteer-extra");
const fs = require('fs');
// add stealth plugin and use defaults (all evasion techniques)
const pluginStealth = require("puppeteer-extra-plugin-stealth");
puppeteer.use(pluginStealth());
const config = {
urls: {
'ebay': 'https://www.ebay.de/sch/i.html?_from=R40&_trksid=p2380057.m570.l2632.R2.TR12.TRC2.A0.H0.Xsommer.TRS0&_nkw=sommerkleid&_sacat=15724',
'google': 'https://www.google.de/search?q=europe+news',
'bing': 'https://www.bing.com/search?q=news+usa',
'duckduckgo': 'https://duckduckgo.com/?q=hotels+barcelona&t=h_&ia=web',
// 'amazon': 'https://www.amazon.com/s?k=french+press',
// 'google_news': 'https://news.google.com/?hl=de&gl=DE&ceid=DE:de',
// 'news': 'https://www.spiegel.de/',
},
chrome_flags: [
'--disable-infobars',
'--window-position=0,0',
'--ignore-certifcate-errors',
'--ignore-certifcate-errors-spki-list',
async function main() {
console.log('start', scriptName)
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
await page.setViewport({ width: 800, height: 600 })
await page.goto('https://bot.sannysoft.com/')
await page.waitFor(5000)
await page.screenshot({ path: screenshotPath, fullPage: true })
await browser.close()
console.log('end', screenshotPath)
}
main()