Created
August 17, 2015 08:43
-
-
Save b4dtR1p/cf51e3ad686f1f3b5c35 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
import mechanize | |
import os | |
def find_recursively(starturl): | |
br = mechanize.Browser() | |
br.open(starturl) | |
links = br.links() | |
for a in links: | |
print "TEXT: "+a.text | |
if a.text.endswith('/') and a.text != 'Parent directory/': | |
print "Moving into: "+starturl.rstrip('/')+'/'+a.url.lstrip('/') | |
find_recursively(starturl.rstrip('/')+'/'+a.url.lstrip('/')) | |
elif a.text.endswith('.txt'): | |
print "Found .txt: "+a.text | |
f = br.retrieve(starturl.rstrip('/')+'/'+a.url.lstrip('/'))[0] | |
os.rename(f, os.getcwd()+'/'+a.text) | |
find_recursively("https://media.defcon.org") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment