Open vesper8 opened 3 years ago
just dedent the try except block. it shouldn't be run in the context manger.
with driver:
driver.get(url)
try:
xpath = '//*[@class="someclass"]'
W ebDriverWait(driver,8).until(EC.presence_of_element_located((By.XPATH, xpath)))
except TimeoutException:
exit()
also, the exit part makes you need to restart the program? in that case I recommend (somehow) saving the cookies (which include a cf pass). it can raise suspicion if you you challenge too often (while regular users just challenge once in a while)
So I'm having some luck using this library to get past Cloudflare. It isn't working 100% of the time and I'm sure there's things I could improve to make it work better. But it's getting past Cloudflare at least 50% of the time. The issue is that I struggle to detect when it has gotten past, and I also struggle to tell the driver to wait for longer.
Here's the part of my code I struggle with
Basically with the above code, if I manage to skip Cloudflare entirely, then it will find that class and all is good. But if I hit cloudflare for a few seconds, and then get redirected to the page I want.. it will fail because it's already looked for the class on the cloudflare page, didn't find it, and thus it fails.
How can I detect when I'm no longer on the cloudflare detection page, and I've arrived on the content page, so that the
WebDriverWait
only executes at that point?I've tried increasing the timeout in my
WebDriverWait
above, it does wait for longer and quite often that gets me past Cloudflare.. but then it ends up waiting for the whole timeout and enters the TimeoutException because it doesn't re-search the page content for my class after the Cloudflare redirect.I hope I'm making sense.. any help would be appreciated