Last active
August 22, 2018 15:34
-
-
Save xd009642/76aaf4e73992b9920ad7829578cc166d to your computer and use it in GitHub Desktop.
This file contains 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
# | |
# Downloads a random RFC and saves to text file. | |
# | |
import random | |
import urllib.request | |
MAX_RFC = 8449 | |
while True: | |
choice = random.randint(1, MAX_RFC) | |
url = "http://www.ietf.org/rfc/rfc{}.txt".format(choice) | |
with urllib.request.urlopen(url) as response: | |
contents = response.read() | |
if "was never issued" not in str(contents): | |
print("Downloaded "+url); | |
f = open("rfc{}.txt".format(choice), "wb") | |
f.write(contents) | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment