Is your scraper getting blocked with a "Please Verify You Are Human" or a "Press & Hold" screen?Â
The website's CAPTCHA is working against you. Fortunately, there's a way out!
In this article, you'll learn two methods to bypass the human verification process during scraping. We'll start with a basic method that requires a complex setup and then teach you the easiest and most reliable solution.
Let's go!
What Is "Please Verify You Are a Human" From PerimeterX?
The "Please verify you are a human" message means the website owner wants you to confirm you're a human user, not a bot. This action prevents malicious programs from accessing the website.Â
Unfortunately, it may also appear when scraping with tools like Selenium or Playwright, blocking you from obtaining your target data.
To verify, you'll be given a task that's easy for humans but hard for bots, such as solving a visual puzzle, answering a question, or performing a specific action. Bypassing PerimeterX (known as HUMAN nowadays) typically requires the "Press & Hold" action screen similar to the one below:
In the next section, you'll see how to bypass the above PerimeterX "Press & Hold to confirm you are a human (and not a bot)" CAPTCHA.
How Do I Avoid "Please Verify / Press & Hold to Confirm You Are a Human" From PerimeterX?
We'll present two techniques to bypass the PerimeterX human verification anti-bot message. The first is a free method that can work for smaller web scraping tasks, while the other is a foolproof paid solution suitable for large-scale scraping.
1. Basic Solution: Press and Hold With a Headless Browser
A headless browser scraper lacks the graphical user interface (GUI) but allows you to automate user interactions with web pages, such as clicking, scrolling, submitting forms, etc.
Since the PerimeterX error typically appears during the initial request to a protected website, a headless browser such as Selenium can mimic the "Press & Hold" action. Let's see how to do it.
PerimeterX typically injects the "Press & Hold" button into a random iframe among other iframe siblings and renders them all in a closed shadow DOM. That makes the Shadow DOM content inaccessible to your Selenium driver for direct JavaScript execution.
Fortunately, there's a way out!Â
Even though the button is in a closed shadow DOM, you can still focus it using the Action API keystrokes of Selenium. You'll use the keystroke Tab key method to focus on the CAPTCHA button and simulate pressing it with the Enter key.
Let's test this out on Zillow, a PerimeterX-protected website.Â
First, import the necessary dependencies and set up your Selenium driver:
# pip install selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
# create a new Chrome webdriver instance, passing in the options object
driver = webdriver.Chrome()
driver.get("https://www.zillow.com/")
# implicitly wait for the DOM to load
driver.implicitly_wait(10)
Once the challenge loads, send the Tab and Enter strokes using the Action Chain, as shown below. The try/except
block ensures you can catch errors in case the "Press & Hold" button isn't on the loaded page:
try:
# initialize for low-level interactions
action = ActionChains(driver)
# focus on the button with the Tab button
action.send_keys(Keys.ENTER)
action.pause(5)
action.send_keys(Keys.TAB)
action.pause(5)
# press and hold the Enter key to simulate "Press & Hold"
action.key_down(Keys.ENTER)
action.pause(10)
# release the Enter key after pressing it for 10 minutes
action.key_up(Keys.ENTER)
action.perform()
# execute the Action Chain
action.perform()
# keep holding for 10s
time.sleep(10)
except Exception as error:
print(f"An {error} occurred and PRESS & HOLD button not found")
# ...continue scraping
# quit the browser and release its resources
driver.quit()
Combine the snippets. Here's the final code:
# pip install selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
# create a new Chrome webdriver instance, passing in the options object
driver = webdriver.Chrome()
driver.get("https://www.zillow.com/")
# implicitly wait for the DOM to load
driver.implicitly_wait(10)
try:
# initialize for low-level interactions
action = ActionChains(driver)
# focus on the button with the Tab button
action.send_keys(Keys.ENTER)
action.pause(5)
action.send_keys(Keys.TAB)
action.pause(5)
# press and hold the Enter key to simulate "Press & Hold"
action.key_down(Keys.ENTER)
action.pause(10)
# release the Enter key after pressing it for 10 minutes
action.key_up(Keys.ENTER)
action.perform()
# execute the Action Chain
action.perform()
# keep holding for 10s
time.sleep(10)
except Exception as error:
print(f"An {error} occurred and PRESS & HOLD button not found")
# ...continue scraping
# quit the browser and release its resources
driver.quit()
The "Press & Hold" simulation works! See it below:
While this method helps with the "Press & Hold" simulation, PerimeterX might still detect you as a bot because headless browsers like Selenium have bot-like properties like the automated WebDriver.Â
To avoid that, you can use a dedicated web scraping tool, which leads us to the next solution.
2. Use a Web Scraping API for Guaranteed Results
PerimeterX uses many detection techniques, such as fingerprinting and behavior analysis. So, the "Please verify that you are human" challenge could come up at any time when scraping.Â
To support the previous method, you can strengthen your headless browser by fixing known vulnerabilities. For example, extensions like the Undetected ChromeDriver for Selenium or the Puppeteer Stealth plugin will decrease the likelihood of anti-bot software identifying automated WebDrivers.
Keep in mind that the security level for PerimeterX differs from site to site. For example, the "Press & Hold" button may be difficult to select, or you may face additional protection from PerimeterX alternatives. As a result, keeping up with bypass strategies takes time and effort.
Paid solutions like web scraping APIs are the most reliable way to bypass PerimeterX because they consistently keep up with evolving anti-bot measures. Unlike free solutions, scraper APIs work close to 100% of the time and perform all the bypass tasks under the hood without manual setups and updates.
One of the best web scraping APIs that guarantees success is ZenRows. It's a full-fledged scraping toolkit that helps you bypass any anti-bot measure at scale using a single API call. ZenRows is also compatible with any programming language and features headless browsing functionalities to scrape dynamic content. It also prevents the anti-bot measure from detecting your IP address by routing your requests through premium rotating proxies.
Let's show you how it works against the PerimeterX protection on the previous target site (Zillow):
Sign up to open the ZenRows Request Builder. Paste your target URL in the link box and activate Premium Proxies and JS Rendering. Select Python as your favorite programming language (Python, in this case). Then, choose the API connection mode.
# pip install requests
import requests
url = "https://www.zillow.com/"
apikey = "<YOUR_ZENROWS_API_KEY>"
params = {
"url": url,
"apikey": apikey,
"js_render": "true",
"premium_proxy": "true",
}
response = requests.get("https://api.zenrows.com/v1/", params=params)
print(response.text)
The above code outputs the target website's full-page HTML, showing that you've successfully bypassed PerimeterX:
<html lang="en">
<head>
<!-- ... -->
<title>
Zillow: Real Estate, Apartments, Mortgages & Home Values
</title>
<!-- ... -->
</head>
<body>
<!-- ... -->
</body>
</html>
Congratulations 🎉! Your scraper now bypasses PerimeterX using ZenRows.Â
Conclusion
You've learned how to bypass PerimeterX using two techniques. While free solutions like headless browsers may help, they don't guarantee success against the PerimeterX anti-bot measures.
The easiest way to bypass the PerimeterX "Please Verify You Are a Human" or "Press & Hold" CAPTCHA is to use a web scraping API like ZenRows. This solution gives you access to any PerimeterX-protected website with a single API call.
Try ZenRows for free now without a credit card!