Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting <response[200]> with Python http requests instead of INT

Im trying to create simple python code that would communicate with 9kw.eu captcha solving service through their api https://www.9kw.eu/api.html#apisubmit-tab. Basically I'm sending base64 encoded image with some keys:values and response from server should be number like: 58952554, but I'm only getting

<response[200]>

Which should mean that the server got my data, but im not getting anything else. I'm able to get the right result with simple html form:

    <form method="post" action="https://www.9kw.eu/index.cgi" enctype="multipart/form-data"> 
KEY:<br>
<input  name="apikey" value="APIKEY"><br>
ACTION<br>
<input  name="action" value="usercaptchaupload"><br>
FILE:<br>
<input name="file-upload-01" value="BASE64IMAGEDATAHERE"><br>
TOOL<br>
<input  name="source" value="htmlskript"><br>
ROTATE<br>
<input  name="rotate" value="1"><br>
Angle<br>
<input  name="angle" value="40"><br>
BASE64
<input  name="base64" value="1"><br>
Upload:<br>
<input type="submit" value="Upload and get ID">
</form>

This is the python code, which should do the same thing:

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('https://www.9kw.eu/index.cgi', data = udajepost)
print(r)

Thanks for any help.

like image 936
user3281831 Avatar asked Apr 11 '17 19:04

user3281831


2 Answers

You're looking for the response of the request:

print(r.text)

In this way you'll have the plain text response.

like image 196
girorme Avatar answered Sep 25 '22 06:09

girorme


r = requests.post('https://www.9kw.eu/index.cgi', data = udajepost)

Here, r is the whole response object which has many attributes. I guess, you only need r.text. So, you can just use:

print(r.text) 
like image 26
Ahsanul Haque Avatar answered Sep 26 '22 06:09

Ahsanul Haque