CAPTCHA Solving
Using Hyperbrowser's CAPTCHA Solving
Last updated
Using Hyperbrowser's CAPTCHA Solving
Last updated
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.
First, lets create a new Node.js project.
Next, let's install the necessary dependencies to run our script.
To use Hyperbrowser with your code, you will need an API Key. You can get one easily from the . Once you have your API Key, add it to your .env
file as HYPERBROWSER_API_KEY
.
Next, create a new file index.js
and add the following code:
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
method
Print 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:
Let's break down the key parts:
We create a new Hyperbrowser session with solveCaptchas
, adblock
, annoyances
, and trackers
set to true
. 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 and stop the Hyperbrowser session.
Without the solveCaptchas
enabled, we could 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.
If you are trying to solve simple image based captchas (the kind which get input into a text box for verification), you also have to add the imageCaptchaParams
field. It takes an array of objects. Each object has a parameter for image selector and input selector. Together, these are used to specify where the source of a captcha will come from, and the input box into which the solution will have to be filled in.
The selectors follow the standard html query-selector format .