Open vndhote opened 1 year ago
I found out that if you open a new tab with js it passes cloudflare captchas. You can close the old tab and use the new one.
driver.execute_script('''window.open("http://nowsecure.nl","_blank");''') # open page in new tab time.sleep(5) # wait until page has loaded driver.switch_to.window(window_name=driver.window_handles[0]) # switch to first tab driver.close() # close first tab driver.switch_to.window(window_name=driver.window_handles[0] ) # switch back to new tab time.sleep(2) driver.get("https://google.com") time.sleep(2) driver.get("https://nowsecure.nl") # this should pass cloudflare captchas now
thanks, bro. Everything works.
I found out that if you open a new tab with js it passes cloudflare captchas. You can close the old tab and use the new one.
driver.execute_script('''window.open("http://nowsecure.nl","_blank");''') # open page in new tab time.sleep(5) # wait until page has loaded driver.switch_to.window(window_name=driver.window_handles[0]) # switch to first tab driver.close() # close first tab driver.switch_to.window(window_name=driver.window_handles[0] ) # switch back to new tab time.sleep(2) driver.get("https://google.com") time.sleep(2) driver.get("https://nowsecure.nl") # this should pass cloudflare captchas now
Youre absolutely right, but at the the same time I just tried to comment out the '--headless' line and it works perfect too without any long loading
Here's my working code version:
from selenium import webdriver
import time
from config import proxy_ip, proxy_port # you can remove it and the option below
options = webdriver.ChromeOptions()
# options.add_argument("--headless")
options.add_argument(f"--proxy-server={proxy_ip}:{proxy_port}")
options.add_argument('--user-data-dir=/home/iprahka/.config/google-chrome/Default')
driver = undetected_chromedriver.Chrome(options)
driver.get('https://www.nowsecure.nl')
time.sleep(99)
i saw this tool online garantee cloudflare verfication to be solved
cons: the documentation is in chinese and couldn't link it with selenium.
Apperently that's an issue with the cloudflare captchas. I found that it works when dev tools are open. Adding the following line resolved the issue for me.
chrome_options.add_argument("--auto-open-devtools-for-tabs") # automatically open dev tools on every new tab
(This is a not a pretty solution ofc, I had no time to dive deeper yet)I tried your solutions, this and the new one and it works on my local machine. However it cannot seem to work on AWS ec2 or Digitalocean droplet. Do you have any pointers where to look to solve this?
are you using package for rendering ? For example: Xvfb
Apperently that's an issue with the cloudflare captchas. I found that it works when dev tools are open. Adding the following line resolved the issue for me.
chrome_options.add_argument("--auto-open-devtools-for-tabs") # automatically open dev tools on every new tab
(This is a not a pretty solution ofc, I had no time to dive deeper yet)I tried your solutions, this and the new one and it works on my local machine. However it cannot seem to work on AWS ec2 or Digitalocean droplet. Do you have any pointers where to look to solve this?
are you using package for rendering ? For example: Xvfb
I am, I can relate to having issues automating my browsers whenever the system is headless and I rely on Xfvb. Any ideas why or tips to avoid detection of headless systems?
undetected chromedriver worked well till yesterday but now, cloudflare improved and the chromedriver is not bypassing cloudflare. I have attached the screenshot of it. cloudflare is just looping the captcha when selenium is running. When I close it, the website loads. This is my code snippet It works fine when the script isn't running. I also tried changing the binary to chrome rather than brave, but the issue still persists