'''
This script helps you download pdf files from remote destinations
@author Gan Tu
@version python 2
'''

import urllib
import re

# change this to the source url you are scrapping from
source = 'http://inst.eecs.berkeley.edu/~ee16a/fa16/dis/'

html = urllib.urlopen(source).read()

# change this to your target regex
regex = '<a href="(ans.+?.pdf)">.+</a>'
pattern = re.compile(regex)
titles = re.findall(pattern, html)

for pdf in titles:
    url = source + pdf
    print "downloading " + pdf + "..."
    file = open(pdf, "w")
    file.write(urllib.urlopen(url).read())
    file.close()
    print "success."
@@ -95,16 +95,255 @@
 python 2
+%0A%0A%5BHOW TO CHANGE PYTHON VERSION%5D%0A%0AThis script by default should be run by Python 2.%0ATo use this in Python 3, change the followings:%0A%0A1) change ALL occurrences of %22urllib%22 to %22urllib.request%22. %0A2) change print %22success.%22 to  print(%22sucess%22)
 %0A'''%0A%0Aim

add instruction to use script for python3