Sunday, March 11, 2012

Downloading book "Foundations of Computer Science"

This small python script would download all chapters in the book "Foundations of Computer Science".


import sys
from subprocess import call  # for 'call'

urlbase = ''

others = ['preface.pdf', 'toc.pdf', 'index.pdf']
chapters = range(1,15)
links = []

def download(index, f):
    url = urlbase + f
    print "file = ", index+1, url
    call(["wget", url])

for ch in chapters:
    links.append('ch' + '%02d' %(ch) + '.pdf')

out = [download(index,obj) for index,obj in enumerate(links)]

print "out=", out

No comments:

Post a Comment