geonode logo

How To Use Proxies With Puppeteer

Puppeteer is a node library that gives its users a high-level headless Chrome API. Here's how to create a proxy server for it!

Carl Gamutan

by Carl Gamutan

Publishing Date: April 8, 2022


Puppeteer is a node library that gives its users a high-level headless Chrome API. Through it, users can take endless screenshots of websites and save web pages as a PDF. There are also many more tasks Puppeteer can do including: submitting forms, generating pre-rendered content, entering keyboard commands, testing chrome extensions, and many more.

Advanced tasks like web scraping and other tasks that involve automation can also be done through Puppeteer. However, if you only use Puppeteer to do those tasks, there’s a good chance that your IP address will be banned. Most websites have strict anti-bot policies and have set up systems to detect bot activity. Any account caught using a bot will be immediately banned.

To bypass these restrictions, you need the help of a Puppeteer proxy. A Puppeteer proxy will handle all of your web requests, including your bot’s requests. Any website you visit will only be able to see the IP address of the proxy server and not your own. Through rotating proxies at set intervals, all of your requests will be coming from different IP addresses making it difficult to detect the fact that you’re using a bot.

If you’re mainly using Puppeteer for advanced tasks like web automation or web scraping, then the best Puppeteer proxies you can use would be residential proxies. Residential proxies use real residential IPs from actual devices making your bot’s requests appear as if it were from various users instead of it coming from a single IP.

Let’s set up a Puppeteer proxy server.

Note: Make sure that the web browser you’re using for Puppeteer is set to automatically copy your computer’s proxy settings. Google Chrome automatically does this, so it’s recommended to use it.

How To Use Proxies With Puppeteer

For Windows:

To set up proxies in Windows, simply search for “Proxy Settings” in your windows search bar and open the search result.

windowsproxysettings.png

You are then given two options to choose from: Automatic proxy setup or Manual proxy setup. If you want windows to automatically detect your proxy settings, choose the first option. Choose the second option if you want to utilize a specific ip address and port number.

If you chose the first option, then:

  1. Turn on Automatically detect Settings
  2. Turn on Use setup script
  3. Enter the script address
  4. Click Save

windowsautomaticsetup.png

If you chose the second option, then:

  1. Turn on Use a proxy server
  2. Input both server address and port number
  3. If you have any addresses you would like to visit without a proxy, enter them here
  4. Turn on Don’t use the proxy server for local addresses check box if you want to access a local server without a proxy
  5. Click Save

windowsmanualsetup.png

For Mac.

To start configuring your proxy settings in MacOS, simply:

Step 1. Click on the Apple Icon.

macAppleIcon.png

Step 2. On the drop down menu, click on “System Preferences”.

macSystemPreferences.png

Step 3. Click on “Network”

macNetwork.png

Step 4. Click on “Advanced”

macNetworkAdvancedSettings.png

Note: Make sure to connect to your wi-fi first.

Step 5. Click on “Proxies”

macNetworkProxySettings.png

This should then redirect you to MacOS proxy settings. MacOS is more straightforward compared to windows. You only have one option which is to manually configure your proxy server.

Here are the steps to follow:

  1. Select which proxy IP protocol you want to configure. This depends on which protocols your proxy service provider offers.
  2. Turn on Secure Web Proxy
  3. Input the Proxy Server Address and Port Number
  4. Click OK to save the configurations

Note: You may be prompted for your Mac user password to save your settings.

macProxySetup.png

Congratulations! You have now finished configuring a Puppeteer proxy server. Note that the first time you visit it, there will be a pop up asking for your login credentials.

Read more similar post... Sitemap