我正在使用python来解决http://hackthis.co.uk
上的Captcha level 1这是代码
from PIL import Image
import pytesseract
import requests
from StringIO import StringIO
url = "https://www.hackthis.co.uk/levels/captcha/1"
login = "https://www.hackthis.co.uk/?login"
payload = {"username": "user", "password": "pass"}
def solve(captcha):
pytesseract.image_to_string(Image.open(captcha))
# other code needs to be writted
return "abc";
s = requests.Session() # Start a session
s.post(login, data=payload) # Login
response = s.get(url).text # Get problem data
captcha = s.get("https://www.hackthis.co.uk/levels/extras/captcha1.php")
captcha = Image.open(StringIO(captcha.content))
captcha.save("E:/captcha1.png")
solution = solve("E:/captcha1.png")
payload = {"answer": solution}
s.post(url, data=payload) # Post data
但我收到了错误
完整日志在这里http://pastebin.com/7T9aKnPN
如果需要,这里是subprocess.py http://pastebin.com/zmkbhgj6
我在其他论坛上尝试了所有其他解决方案但没有帮助
提前致谢:)
编辑:问题只发生在使用pytesseract.image_to_string()方法时
答案 0 :(得分:0)
Well the problem was, tesserect wasn't installed! i downloaded this Tesserect OCR executables from the download page
then added the downloaded directory to PATH
variable
Installed VC2015 x86 redist (required)
Worked for me :D