Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A tutorial for implementing Oxylabs` Residential and Datacenter proxies with Puppeteer using JavaScript

NotificationsYou must be signed in to change notification settings

oxylabs/puppeteer-proxy-integration-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Oxylabs promo code

YouTube

Requirements

Puppeteer

npm install puppeteer

Integrating Datacenter Proxies

Getting a List of Proxies

Open the following URL in the browser and enter your credentials. You will see a list of proxies in plain text:

https://proxy.oxylabs.io/all

Using Proxies

If you wish to select any of the provided proxies, save the proxy IP, along with the port in a variable.

To use all these proxies, first, save these proxies as an array in your code:

letproxies=['127.0.0.1:60000','127.0.0.2:60000','127.0.0.3:60000','127.0.0.4:60000']

To select one of these proxies randomly, use the following line of code:

varproxy=proxies[Math.floor(Math.random()*proxies.length)];

The proxy server you will use needs to be supplied as--proxy-server argument.

Create a variable that can contain all the arguments in an array.

Additionally,launchOptions can also contain other information, such asheadless mode as following:

constlaunchOptions={// Set the proxy server to the server variableargs:['--proxy-server='+proxy],// Set additional launch options hereheadless:false};

After creating thelaunchOptions variable, create apuppeteer instance and launch the browser.

constbrowser=awaitpuppeteer.launch(launchOptions);

Finally, to authenticate using your credentials, call thepage.authenticate function after creating apage.

// Create a new pageconstpage=awaitbrowser.newPage();// Set the username and password provided by Oxylabsawaitpage.authenticate({username:'USERNAME',password:'PASSWORD'});

For the complete code sample, seethis file.

Integrating Residential Proxies

Random Proxy Using the Proxy API

To get a random proxy, use the proxy serverpr.oxylabs.io:7777.

As mentioned above, the proxy server you will use needs to be supplied as--proxy-server argument.

Create a variable that can contain all the arguments in an array.

Additionally,launchOptions can also contain other information, such asheadless mode as following:

constlaunchOptions={// Set the proxy server to the server variableargs:['--proxy-server=pr.oxylabs.io:7777']};

After creating thelaunchOptions variable, create apuppeteer instance and launch the browser.

constbrowser=awaitpuppeteer.launch(launchOptions);

Finally, to authenticate using your credentials, call thepage.authenticate function after creating apage.

// Create a new pageconstpage=awaitbrowser.newPage();// Set the username and password provided by Oxylabsawaitpage.authenticate({username:'USERNAME',password:'PASSWORD'});

For the complete code sample, seethis file.

Country Specific Proxies

If you wish to use country-specific proxies, all you need to do is change theproxy server.

For example, if you want to use a proxy for the United States, you can use the following code:

constlaunchOptions={args:['--proxy-server=us-pr.oxylabs.io:10001']};

In this example,us-pr.oxylabs.io:10000 is the country specific entry point for the United States.

Another example isgb-pr.oxylabs.io:20000, which is the country specific entry point for the United Kingdom.

For a complete list of all entry points, seeCountry Specific Entry Nodes

Releases

No releases published

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp