- #1
adjacent
Gold Member
- 1,552
- 63
I am experimenting with capatcha images. I have a capatcha.php in my local host which will generate an image and that image will be put into the form
Here is my python code to get the image, extract the text in it and send them back to the form. And finally save the resulting form as html.
The form has Two fields, Number and Code. And it will return a table of things.
But it's not working. The html saved by python does not have the table. I don't see any problem with the code
Here is my python code to get the image, extract the text in it and send them back to the form. And finally save the resulting form as html.
The form has Two fields, Number and Code. And it will return a table of things.
But it's not working. The html saved by python does not have the table. I don't see any problem with the code
Code:
import os
import requests
p = requests.session()
q = p.get('[PLAIN]http://localhost/Test/Capatcha.php')[/PLAIN]
with open('data/a.png', 'wb') as f:
f.write(q.content)
os.system("tesseract C:\\Users\\Me\\Desktop\\Test\\data\\a.png C:\\Users\\Me\\Desktop\\Test\\data\\a")
with open("data\\a.txt") as cap:
capData = cap.read()
print("Capatcha line:"+capData)
num = input("Please enter the number :")
payload = {
'Code': capData,
'q': num
}
url = "[PLAIN]http://localhost/Test/index.php"[/PLAIN]
r = p.post(url, data=payload)
with open("data\\log.html", "w") as file:
log = file.write(r.text)
Last edited by a moderator: