Skip to content

Commit d845977

Browse files
authored
Update download.py
fixes some exception in python3, and removed an unused import "urllib2" which causes an error in python3 either.
1 parent be372fc commit d845977

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

download.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from __future__ import print_function
22
import os
33
import re
4-
from six.moves.urllib.request import urlopen
54
from six.moves.urllib.error import HTTPError
6-
import urllib2
75
import shutil
86
import argparse
97
import mistune
@@ -14,9 +12,14 @@
1412

1513
# encoding=utf8
1614
import sys
17-
18-
reload(sys)
19-
sys.setdefaultencoding('utf8')
15+
try:
16+
reload(sys)
17+
except NameError:
18+
pass
19+
try:
20+
sys.setdefaultencoding('utf8')
21+
except AttributeError:
22+
pass
2023

2124
def download_pdf(link, location, name):
2225
try:

0 commit comments

Comments
 (0)