crawler: make py2/3 code distinction clearer
parent
5d93d68f62
commit
91a084e5ed
|
@ -12,15 +12,19 @@ import lxml.html
|
|||
import time
|
||||
|
||||
try:
|
||||
# python 2
|
||||
from urllib2 import BaseHandler, HTTPCookieProcessor, Request, addinfourl, parse_keqv_list, parse_http_list, build_opener
|
||||
import mimetools
|
||||
except ImportError:
|
||||
# python 3
|
||||
from urllib.request import BaseHandler, HTTPCookieProcessor, Request, addinfourl, parse_keqv_list, parse_http_list, build_opener
|
||||
import email
|
||||
|
||||
try:
|
||||
# python 2
|
||||
basestring
|
||||
except NameError:
|
||||
# python 3
|
||||
basestring = unicode = str
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue