crawler: make py2/3 code distinction clearer
This commit is contained in:
		@@ -12,15 +12,19 @@ import lxml.html
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
 | 
					    # python 2
 | 
				
			||||||
    from urllib2 import BaseHandler, HTTPCookieProcessor, Request, addinfourl, parse_keqv_list, parse_http_list, build_opener
 | 
					    from urllib2 import BaseHandler, HTTPCookieProcessor, Request, addinfourl, parse_keqv_list, parse_http_list, build_opener
 | 
				
			||||||
    import mimetools
 | 
					    import mimetools
 | 
				
			||||||
except ImportError:
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # python 3
 | 
				
			||||||
    from urllib.request import BaseHandler, HTTPCookieProcessor, Request, addinfourl, parse_keqv_list, parse_http_list, build_opener
 | 
					    from urllib.request import BaseHandler, HTTPCookieProcessor, Request, addinfourl, parse_keqv_list, parse_http_list, build_opener
 | 
				
			||||||
    import email
 | 
					    import email
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
 | 
					    # python 2
 | 
				
			||||||
    basestring
 | 
					    basestring
 | 
				
			||||||
except NameError:
 | 
					except NameError:
 | 
				
			||||||
 | 
					    # python 3
 | 
				
			||||||
    basestring = unicode = str
 | 
					    basestring = unicode = str
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user