Skip to content

Instantly share code, notes, and snippets.

@xd009642
Last active August 22, 2018 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xd009642/76aaf4e73992b9920ad7829578cc166d to your computer and use it in GitHub Desktop.
Save xd009642/76aaf4e73992b9920ad7829578cc166d to your computer and use it in GitHub Desktop.
#
# 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