From 9dcb55174a2759266704364aaa48f3bcda065de8 Mon Sep 17 00:00:00 2001 From: kingzero Date: Tue, 16 Jun 2009 17:13:21 +0200 Subject: added captcha support for gigasize.com, see #6 --- captcha/captcha.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 captcha/captcha.py (limited to 'captcha/captcha.py') diff --git a/captcha/captcha.py b/captcha/captcha.py new file mode 100644 index 000000000..b57fa1b7e --- /dev/null +++ b/captcha/captcha.py @@ -0,0 +1,25 @@ +import Image +import ImageOps +import subprocess + +class Ocr(object): + def __init__(self, image): + self.image = Image.open(image) + self.image_name = 'captcha_clean.png' + self.result_captcha = '' + + + def threshold(self, value): + self.image = self.image.point(lambda a: a * value +10) + + def run_gocr(self): + self.image.save(self.image_name) + cmd = ['gocr', self.image_name] + self.result_captcha = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].replace('\n','') + + def get_captcha(self): + pass + +if __name__ == '__main__': + ocr = Ocr('gigasize-com/7.jpg') + print ocr.get_captcha() -- cgit v1.2.3