Skip to content

Commit

Permalink
add 2 & 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
clouds56 committed Apr 6, 2017
1 parent 109889d commit d8c58cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions download.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
from __future__ import print_function
import os
import re
import urllib2
from six.moves.urllib.request import urlopen
from six.moves.urllib.error import HTTPError
import shutil
import argparse
import mistune
import bs4 as BeautifulSoup
import socket

def download_pdf(link, location, name):
try:
response = urllib2.urlopen(link, timeout=500)
response = urlopen(link, timeout=500)
file = open(os.path.join(location, name), 'w')
file.write(response.read())
file.close()
except urllib2.HTTPError:
except HTTPError:
print('>>> Error 404: cannot be downloaded!\n')
raise
except socket.timeout:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mistune>=0.7.2
beautifulsoup4>=4.4.1
beautifulsoup4>=4.4.1
six>=1.10.0

0 comments on commit d8c58cd

Please sign in to comment.