Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

Getting with Python http requests instead of INT

Asked by Elayne Balding Apr 14, 2021 1.2K views 1 answer
Share

About this question

 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)

Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.