Getting with Python http requests instead of INT

534    Asked by ElayneBalding in Python , Asked on Apr 14, 2021

 Let me create a simple python code that would communicate with captcha solving service through their API. With some keys: values, I would be sending base64 encoded image and the response from the server should be in number: 58952554, But I'm not getting those numbers, instead, I'm getting This means that server had got my data, but I'm not getting anything else. 

With the help of HTML, I can able to get the right result,

 
KEY:<input  name="apikey" value="APIKEY">

</input >
ACTION<input  name="action" value="usercaptchaupload">

</input >
FILE:

<input name="file-upload-01" value="BASE64IMAGEDATAHERE" fdprocessedid="36bh2a">

TOOL<input  name="source" value="htmlskript">

</input >
ROTATE
<input  name="rotate" value="1">

</input >
Angle
<input  name="angle" value="40">

</input >
BASE64<input  name="base64" value="1">

</input >
Upload:

<input type="submit" value="Upload and get ID" fdprocessedid="khopz">

The below program should do the same thing (Python code):

import requests
import time
#base64 image encoding
with open("funcaptcha1.png", "rb") as f:
    data = f.read()
    filekodovany = data.encode("base64")
    #captcha uploader
udajepost = {'apikey':'APIKEY','action':'usercaptchaupload','file-upload-01':filekodovany,'source':'pythonator','rotate':'1','angle':'40','base64':'1'}
headers = {'Content-Type':'multipart/form-data'}
r = requests.post( data = udajepost)
print(r)

Answered by Elayne Balding

 In the below code, 'r' is the whole response 200 python object which will have many attributes. I thought you need only r.text

So, you can just use:
print(r.text)

Your Answer

Interviews

Parent Categories