fork(3) download
  1. from PIL import Image
  2. from PIL import ImageEnhance
  3. from pytesser import *
  4. from requests import Session
  5. from StringIO import StringIO
  6.  
  7. s = Session() # this session will hold the cookies
  8.  
  9. # here we first login and get our session cookie
  10. s.post("https://w...content-available-to-author-only...o.uk?login",{"username":"username","password":"password"})
  11.  
  12. # now we're logged in and can request any page
  13. resp = s.get("https://w...content-available-to-author-only...o.uk/levels/extras/captcha1.php")
  14.  
  15. i = Image.open(StringIO(resp.content))
  16. i.save('captcha1.php.png')
  17.  
  18. #opens image and resizes it
  19. im = Image.open("captcha1.php.png")
  20. nx, ny = im.size
  21. im2 = im.resize((int(nx*5), int(ny*5)), Image.BICUBIC)
  22. im2.save("temp2.png")
  23.  
  24. #opens resized image and reads text
  25. image = Image.open('temp2.png')
  26. answer = image_to_string(image)
  27. reverse = answer[::-1]
  28. print reverse
  29.  
  30. s.post("https://w...content-available-to-author-only...o.uk/levels/captcha/1", {"answer":reverse})
Runtime error #stdin #stdout #stderr 0.02s 9808KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 3, in <module>
ImportError: No module named pytesser