File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change
1
+ from __future__ import print_function
1
2
import os
2
3
import re
3
- import urllib2
4
+ from six .moves .urllib .request import urlopen
5
+ from six .moves .urllib .error import HTTPError
4
6
import shutil
5
7
import argparse
6
8
import mistune
7
9
import bs4 as BeautifulSoup
10
+ import socket
8
11
9
12
def download_pdf (link , location , name ):
10
13
try :
11
- response = urllib2 . urlopen (link , timeout = 500 )
14
+ response = urlopen (link , timeout = 500 )
12
15
file = open (os .path .join (location , name ), 'w' )
13
16
file .write (response .read ())
14
17
file .close ()
15
- except urllib2 . HTTPError :
18
+ except HTTPError :
16
19
print ('>>> Error 404: cannot be downloaded!\n ' )
17
20
raise
18
21
except socket .timeout :
Original file line number Diff line number Diff line change 1
1
mistune >= 0.7.2
2
- beautifulsoup4 >= 4.4.1
2
+ beautifulsoup4 >= 4.4.1
3
+ six >= 1.10.0
You can’t perform that action at this time.
0 commit comments