Skip to content

Instantly share code, notes, and snippets.

@b4dtR1p
Created August 17, 2015 08:43
Show Gist options
  • Save b4dtR1p/cf51e3ad686f1f3b5c35 to your computer and use it in GitHub Desktop.
Save b4dtR1p/cf51e3ad686f1f3b5c35 to your computer and use it in GitHub Desktop.
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