diff --git a/README.md b/README.md index e6c3f7b..835e3b5 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,11 @@ ### 环境 * Linux Mint 18.2 Cinnamon 64-bit - * python 3.5.2 + * python 3.5.2 or 2.7.12 * scikit-learn 0.19.1 * Pillow 4.3.0 + * scipy + * numpy ### 用法 详见./demo.py diff --git a/demo.py b/demo.py index bbfd6c9..90c4084 100755 --- a/demo.py +++ b/demo.py @@ -26,7 +26,7 @@ start = time.clock() captcha_text = decaptcha.decode(captcha_image) elapsed = (time.clock() - start) -print("Time used:", elapsed) +print('Time used: %f' % elapsed) print('captcha_text: %s' % captcha_text) @@ -35,6 +35,6 @@ start = time.clock() captcha_text = decaptcha_copy.decode(captcha_image) elapsed = (time.clock() - start) -print("Time used:", elapsed) +print('Time used: %f' % elapsed) print('captcha_text: %s' % captcha_text) captcha_image.show() diff --git a/utils.py b/utils.py index 226dc05..d45bb27 100644 --- a/utils.py +++ b/utils.py @@ -1,11 +1,17 @@ #!/usr/bin/env python3 +import sys from PIL import Image -from urllib.parse import urljoin -from html.parser import HTMLParser -from urllib.request import Request, urlopen, urlretrieve from io import BytesIO import re import logging +if sys.version > '3': + from urllib.parse import urljoin + from html.parser import HTMLParser + from urllib.request import Request, urlopen +else: + from urlparse import urljoin + from HTMLParser import HTMLParser + from urllib2 import Request, urlopen class _CaptchaParser(HTMLParser):