Skip to content

Commit

Permalink
support python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
bumzy committed Dec 24, 2017
1 parent baa19a9 commit fd92a64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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()
12 changes: 9 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit fd92a64

Please sign in to comment.