Skip to content

Instantly share code, notes, and snippets.

@dansondergaard
Created September 13, 2011 13:27
Show Gist options
  • Save dansondergaard/1213802 to your computer and use it in GitHub Desktop.
Save dansondergaard/1213802 to your computer and use it in GitHub Desktop.
Fetches tests from dOvs website
import requests
import os
from os.path import splitext, basename
from lxml.html import document_fromstring as parse
ROOT = 'http://www.cs.au.dk/~mis/dOvs/'
DEST = '/home/dan/Desktop/feature_tests/'
r = requests.get('http://www.cs.au.dk/~mis/dOvs/languages.html')
d = parse(r.content)
for elem, _, url, _ in d.iterlinks():
full_url = ROOT + url
print "fetching", full_url
r = requests.get(full_url)
filename, _ = splitext(basename(url))
dest_dir = DEST + 'J1_2_' + filename
print "creating", dest_dir
os.mkdir(dest_dir)
file_path = dest_dir + '/Main.java'
print "saving to ", file_path
f = open(file_path, 'w')
f.write(r.content)
print "done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment