From 91a084e5ed1a85405b600ad2df3f9e8f1af35a7c Mon Sep 17 00:00:00 2001 From: pictuga Date: Thu, 25 Oct 2018 01:14:46 +0200 Subject: [PATCH] crawler: make py2/3 code distinction clearer --- morss/crawler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/morss/crawler.py b/morss/crawler.py index 9f9927e..a7f0820 100644 --- a/morss/crawler.py +++ b/morss/crawler.py @@ -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