There are multiple ways to Evade detection of Selenium automation.
Using --disable-blink-features=AutomationControlled
Code Block:
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.get('https://www.solebox.com/de_DE')
print(driver.page_source)
Console Output:
<!-- =============== This snippet of JavaScript handles fetching the dynamic recommendations from the remote recommendations server
and then makes a call to render the configured template with the returned recommended products: ================= -->
<script>
(function(){
// window.CQuotient is provided on the page by the Analytics code:
var cq = window.CQuotient;
if (cq && ('function' == typeof cq.getCQUserId)
&& ('function' == typeof cq.getCQCookieId)
&& ('function' == typeof cq.getCQHashedEmail)
&& ('function' == typeof cq.getCQHashedLogin)) {
var recommender = '[["Homepage_Topseller"]]';
// cleaning up the leading/trailing brackets and quotes:
recommender=recommender.slice(8, recommender.length-8);
var separator = '|||';
.
</script>
<script type="text/javascript">//<!--
/* <![CDATA[ (viewProduct-active_data.js) */
dw.ac._capture({id: "01900289", type: "recommendation"});
/* ]]> */
// -->
</script>
.
<script type="text/javascript" id="" src="//static.criteo.net/js/ld/ld.js"></script>
<script type="text/javascript" id="">window.criteo_q=window.criteo_q||[];window.criteo_q.push({event:"setAccount",account:google_tag_manager["GTM-M9TMD24"].macro(24)},{event:"setEmail",email:""},{event:"setSiteType",type:"d"},{event:"viewHome"});</script><div id="criteo-tags-div" style="display: none;"><iframe src="https://gum.criteo.com/syncframe?topUrl=www.solebox.com#{"bundle":{"origin":0,"value":null},"cw":true,"lwid":{"origin":0,"value":null},"optout":{"origin":0,"value":null},"origin":"onetag","pm":0,"sid":{"origin":0,"value":null},"tld":"solebox.com","topUrl":"www.solebox.com","uid":null,"version":"5_6_2"}" id="criteo-syncframe" width="0" height="0" frameborder="0" style="border-width:0px; margin:0px; display:none" title="Criteo GUM iframe"></iframe></div></body></html>
You can find a relevant detailed discussion in Selenium can't open a second page
Using undetected_chromedriver
Code Block:
import undetected_chromedriver as uc
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = uc.Chrome(options=options)
driver.get("https://www.solebox.com/de_DE")
print(driver.page_source)
Console Output:
.
.
<script type="text/javascript" id="">!function(b,e,f,g,a,c,d){b.fbq||(a=b.fbq=function(){a.callMethod?a.callMethod.apply(a,arguments):a.queue.push(arguments)},b._fbq||(b._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[],c=e.createElement(f),c.async=!0,c.src=g,d=e.getElementsByTagName(f)[0],d.parentNode.insertBefore(c,d))}(window,document,"script","https://connect.facebook.net/en_US/fbevents.js");fbq("init",google_tag_manager["GTM-M9TMD24"].macro(19));fbq("track","PageView");</script>
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=238536633211197&ev=PageView&noscript=1"></noscript>
<script type="text/javascript" id="" src="//static.criteo.net/js/ld/ld.js"></script></body></html>
You can find a relevant detailed discussion in Undetected Chromedriver not loading correctly