CAPTCHA Solving
Using Hyperbrowser's CAPTCHA Solving
Hyperbrowser's CAPTCHA solving feature requires being on a PAID
plan.
In this guide, we will see how to use Hyperbrowser and its integrated CAPTCHA solver to scrape Today's Top Deals from Amazon without being blocked.
Setup
First, lets create a new Node.js project.
Installation
Next, let's install the necessary dependencies to run our script.
Setup your Environment
To use Hyperbrowser with your code, you will need an API Key. You can get one easily from the dashboard. Once you have your API Key, add it to your .env
file as HYPERBROWSER_API_KEY
.
Code
Next, create a new file index.js
and add the following code:
Run the Scraper
To run the Amazon deals scraper:
In your terminal, navigate to the project directory
Run the script with Node.js:
The script will:
Create a new Hyperbrowser session with captcha solving, ad blocking, and anti-tracking enabled
Launch a Puppeteer browser and connect it to the session
Navigate to the Amazon deals page, solving any CAPTCHAs that are encountered
Wait 10 seconds for the page to load its content
Scrape the deal data using Puppeteer's
page.evaluate
methodPrint the scraped products to the console
Close the browser and stop the Hyperbrowser session
You should see the scraped products printed in the console, like:
How it Works
Let's break down the key parts:
We create a new Hyperbrowser session with
solveCaptchas
,adblock
,annoyances
, andtrackers
set totrue
. This enables the captcha solver and other anti-bot evasion features.We launch a Puppeteer browser and connect it to the Hyperbrowser session.
We navigate to the Amazon deals page and wait for any CAPTCHAs to be solved automatically by Hyperbrowser.
We pause execution for 10 seconds with
sleep
to allow all content to be loaded.We use
page.evaluate
to run JavaScript on the page to scrape the deal data.In the evaluator function, we select the deal elements, extract the relevant data, and return an array of product objects.
We print the scraped data, close the browser, and stop the Hyperbrowser session.
Without the solveCaptchas
enabled, we would encounter a screen like this when trying to navigate to the deals page:
The captcha solver runs automatically in the background, so we don't need to handle captchas explicitly in our script. If a captcha appears, Hyperbrowser will solve it and continue loading the page. In this case, it would solve this CAPTCHA and continue on to the deals page.
Last updated