1.0.2 • Published 2 years ago

zyte-proxy-puppeteer v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Zyte Proxy Puppeteer

made-with-javascript

Use Puppeteer with Smart Proxy Manager easily!

A wrapper over Puppeteer to provide Zyte Smart Proxy Manager specific functionalities.

QuickStart

  1. Install Zyte Proxy Puppeteer
npm install zyte-proxy-puppeteer
  1. Create a file sample.js with following content and replace <SPM_APIKEY> with your SPM Apikey
const puppeteer = require('zyte-proxy-puppeteer');

(async () => {
    const browser = await puppeteer.launch({
        spm_apikey: '<SPM_APIKEY>'
    });
    console.log('Before new page');
    const page = await browser.newPage();

    console.log('Opening page ...');
    try {
        await page.goto('https://toscrape.com/', {timeout: 180000});
    } catch(err) {
        console.log(err);
    }

    console.log('Taking a screenshot ...');
    await page.screenshot({path: 'screenshot.png'});
    await browser.close();
})();

Make sure that you're able to make https requests using Smart Proxy Manager by following this guide Fetching HTTPS pages with Zyte Smart Proxy Manager

  1. Run sample.js using Node
node sample.js

API

ZyteProxyPuppeteer.launch accepts all the arguments accepted by Puppeteer.launch and some additional arguments defined below:

ArgumentDefault ValueDescription
spm_apikey (required)undefinedZyte Smart Proxy Manager API key that can be found on your zyte.com account.
spm_hosthttp://proxy.zyte.com:8011Zyte Smart Proxy Manager proxy host.
static_bypasstrueWhen true ZyteProxyPuppeteer will skip proxy use for static assets defined by static_bypass_regex or pass false to use proxy.
static_bypass_regex/.*?\.(?:txt\|css\|eot\|gif\|ico\|jpe?g\|js\|less\|mkv\|mp4\|mpe?g\|png\|ttf\|webm\|webp\|woff2?)$/Regex to use filtering URLs for static_bypass.
block_adstrueWhen true ZyteProxyPuppeteer will block ads defined by block_list using @cliqz/adblocker-puppeteer package.
block_list['https://easylist.to/easylist/easylist.txt', 'https://easylist.to/easylist/easyprivacy.txt']Block list to be used by ZyteProxyPuppeteer in order to initiate blocker enginer using @cliqz/adblocker-puppeteer and block ads