Skip to content

Add Cloudflare detection step. - #3

Open
lerdem wants to merge 2 commits into
AlexFlipnote:masterfrom
lerdem:master
Open

Add Cloudflare detection step.#3
lerdem wants to merge 2 commits into
AlexFlipnote:masterfrom
lerdem:master

Conversation

@lerdem

@lerdem lerdem commented Mar 31, 2022

Copy link
Copy Markdown

Added Cloudflare detection check. For more obvious error message.

Comment thread index.py

if has_cloudflare_issues:
pretty_print("!", "Failed because of Cloudflare protection!")
raise ValueError(title.text)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will for sure trigger the exception call at the end of the loop

@lerdem lerdem Apr 1, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will trigger the exception. But all program flow is wrapped with try... except (source) block, so that exception will be handled properly.
What do you think?

Comment thread index.py

r = fetch("https://liveuamap.com/")
html = BeautifulSoup(r, "html.parser")
_check_cloudflare(html)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend having this spit a variable instead, and then something like "If True is returned, throw error and wait time before doing a continue back to start"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants