Created
September 20, 2021 04:10
-
-
Save jeremysmitherman/5c08aa075546f7421906974174646052 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import requests | |
base = "https://visualfractions.com/calculator/divisible-by/is-{}-divisible-by-{}/" | |
for x in range(1, 20): | |
print("Checking {} for fizzybuzziness".format(x)) | |
by3 = False | |
by5 = False | |
r = requests.get(base.format(x, 3)) | |
if "<strong>{} is also divisible by 3.</strong>".format(str(x)) in r.text.lower() or "<strong>{} is divisible by 3.</strong>".format(str(x)) in r.text.lower(): | |
by3 = True | |
time.sleep(2) | |
r = requests.get(base.format(x, 5)) | |
if "<strong>{} is also divisible by 5.</strong>".format(str(x)) in r.text.lower() or "<strong>{} is divisible by 5.</strong>".format(str(x)) in r.text.lower(): | |
by5 = True | |
out = "" | |
if by3: | |
out += "fizz" | |
if by5: | |
out += "buzz" | |
if out != "": | |
print(out) | |
time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment