0.0.1 • Published 4 years ago

proxylist-js-sdk v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

ProxyList JS SDK

Installation

With Yarn:

$ yarn add proxylist-js-sdk

With NPM:

$ npm install proxylist-js-sdk

Examples

Searching "Hello World" in Google using proxyFetch()

import ProxyList from 'proxylist-js-sdk'

const googleUrl = 'https://www.google.com/search?q=hello+world&oq=hello+world'
const proxyList = new ProxyList('123', {
    included_text: "hello world",
    url: googleUrl
})

/**
 * Testing node fetch test.
 */
const nodeFetchTest = async () => {
    let response = await proxyList.proxyFetch(googleUrl, {})
    let responsePayload = await response.text()
    console.log({ responsePayload })
}

// Executing the script.
nodeFetchTest()

Searching "Hello World" in Google using puppeteer

import ProxyList from 'proxylist-js-sdk'
import puppeteer from 'puppeteer'

/**
 * Testing puppeteer request.
 */
const puppeteerTest = async () => {

    const googleUrl = 'https://www.google.com/search?q=hello+world&oq=hello+world'
    const proxyList = new ProxyList('123', {
        included_text: "hello world",
        url: googleUrl
    })

    let oneProxy = await proxyList.getOneProxy()
    let proxyAndPort = `${oneProxy?.ip}:${oneProxy?.port}`

    const browser = await puppeteer.launch({ headless: false, args: [`--proxy-server=${proxyAndPort}`] });
    const page = await browser.newPage();
    await page.goto(googleUrl);
    await page.screenshot({ path: 'example.png' });

    await browser.close();
}


puppeteerTest()