summaryrefslogtreecommitdiffstats
path: root/captcha
diff options
context:
space:
mode:
authorGravatar kingzero <devnull@localhost> 2009-06-16 17:13:58 +0200
committerGravatar kingzero <devnull@localhost> 2009-06-16 17:13:58 +0200
commit2482c76a31880e5fc3a32393b56a1e7fca1fe9c4 (patch)
treef9222f225357bf9d55a6538aac5588a0dea01c43 /captcha
parentAdded Zippyshare.com Download Plugin (diff)
parentadded captcha support for gigasize.com, see #6 (diff)
downloadpyload-2482c76a31880e5fc3a32393b56a1e7fca1fe9c4.tar.xz
Diffstat (limited to 'captcha')
-rw-r--r--captcha/__init__.py0
-rw-r--r--captcha/captcha.py25
-rw-r--r--captcha/gigasize-com.py14
3 files changed, 39 insertions, 0 deletions
diff --git a/captcha/__init__.py b/captcha/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/captcha/__init__.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()
diff --git a/captcha/gigasize-com.py b/captcha/gigasize-com.py
new file mode 100644
index 000000000..b48e20da4
--- /dev/null
+++ b/captcha/gigasize-com.py
@@ -0,0 +1,14 @@
+from captcha import Ocr
+
+class Gigasize(Ocr):
+ def __init__(self, image):
+ Ocr.__init__(self, image)
+
+ def get_captcha(self):
+ self.threshold(2.8)
+ self.run_gocr()
+ return self.result_captcha
+
+if __name__ == '__main__':
+ ocr = Gigasize('gigasize-com/7.jpg')
+ print ocr.get_captcha()