Articles on: API

How can I bypass cookie consent page?

Most sites have cookie consent pop-ups, which can be closed via our API. We will use Google as an example, but you can apply the same logic to any website.


Keep in mind that every website is built differently, so cookie consent buttons are not standardized across sites. Each page may use its own unique layout, elements, or wording for cookie banners, which means the buttons must often be identified and handled on a case-by-case basis.


So to fix this issue and bypass it, we need to accept Google's terms, and we have two approaches to do that:


Whenever you accept Google's terms, a cookie with the name CONSENT is saved on your computer. It usually contains a YES+ text with a timestamp and the user's country code. So to mimic this behavior, we can visit the page we want to scrape with a cookie that contains a similar value:


from scrapingbee import ScrapingBeeClient
client = ScrapingBeeClient(api_key='API_KEY')

response = client.get(
'https://www.google.com/search?q=Best+Laptops+in+Europe&tbm=shop',
params={
'custom_google': 'true',
'stealth_proxy': 'true',
'country_code':'gb',
'wait': '1500' # Waiting for the content to load (1.5 seconds)
},
cookies= {'CONSENT': 'YES+'} # Sending a cookie with the request
)

if response.ok:
print(response.content)
# Do whatever you want with the request!
else:
print(response.content)


2. Using a JavaScript Scenario:

With this method, we mimic the exact behavior of a typical EU user: We click on the [I agree] button, and we continue our search!


from scrapingbee import ScrapingBeeClient
client = ScrapingBeeClient(api_key='API_KEY')

response = client.get(
'https://www.google.com/search?q=Best+Laptops+in+Europe&tbm=shop',
params={
'custom_google': 'true',
'stealth_proxy': 'true',
'country_code':'gb',
'js_scenario': {"instructions": [{"click": "form > div > div > button"}]}, # Clicking the agreement button
'wait': '1500' # Waiting for the content to load (1.5 seconds)
}
)

if response.ok:
print(response.content)
# Do whatever you want with the request!
else:
print(response.content)

Updated on: 20/01/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!