Created
September 13, 2011 13:27
-
-
Save dansondergaard/1213802 to your computer and use it in GitHub Desktop.
Fetches tests from dOvs website
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 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