Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cloudflare detection step. #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lerdem
Copy link

@lerdem lerdem commented Mar 31, 2022

Added Cloudflare detection check. For more obvious error message.


if has_cloudflare_issues:
pretty_print("!", "Failed because of Cloudflare protection!")
raise ValueError(title.text)
Copy link
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

Copy link
Author

@lerdem lerdem Apr 1, 2022

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?

@@ -198,6 +213,7 @@ def main():

r = fetch("https://liveuamap.com/")
html = BeautifulSoup(r, "html.parser")
_check_cloudflare(html)
Copy link
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