Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getIndivTrials(newDir):
- import os, urllib2, time, socket
- failedAttempts = []
- #...
- #download the page
- socket.setdefaulttimeout(10)
- try:
- response = urllib2.urlopen(url)
- webContent = response.read()
- #create the filename and place it in the new "trials" directory
- filename = items + '.html'
- filePath = pjoin(newDir, filename)
- #save the file
- f = open(filePath, 'w')
- f.write(webContent)
- f.close
- except:
- failedAttempts.append(url)
- #pause for 3 seconds
- time.sleep(3)
- print "the following files failed to download" + str(failedAttempts)
Add Comment
Please, Sign In to add comment