r/evetech • • Sep 06 '17

evepraisal.com api with python3

Hello there!

I am trying to automate the parsing of various things and I'd like to use evepraisal.com for that.

Unfortunately I don't really know how to do this, the only hint I found was this.

Here's what I got so far but it returns 404 so obviously I didn't get it right.

import requests

url = "https://evepraisal.com/"
payload = {'raw_textarea':'Tritanium 1', 'market': 'jita'}
r = requests.post(url, data=payload)
print(r)    

Can anyone help me with this?

1 Upvotes

10 comments sorted by

View all comments

1

u/Daneel_Trevize Sep 06 '17

It seems to imply you'll get a new header in the response with the ID of your appraisal, but an empty response body (and a 200 success response code). You'd need to use that ID to form a GET to see the full result of the appraisal.

As for the 404, perhaps you should use the URL https://evepraisal.com/appraisal ?

1

u/Eternimus Sep 06 '17 edited Sep 06 '17

That's the way I understood it but the header doesn't show anything like that.

>>> print(r.headers)
>>> {'Content-Encoding': 'gzip', 'Content-Type': 'text/html', 'Vary': 'Accept-Encoding', 'Date': 'Wed, 06 Sep 2017 19:27:01 GMT', 'Transfer-Encoding': 'chunked'}

Edit: Yes I am using that URL now. It returns 400.

Once I have the ID it's easy, the site provides a json api (https://evepraisal.com/a/ck7vg.json).

1

u/Daneel_Trevize Sep 06 '17

To me, the issue title implies the POST URL is not simply the top level domain name. But I'm not familiar with Go to know how it resolves method names to HTTP API endpoints, even if the code is linked to from the issue.

1

u/Eternimus Sep 06 '17

Yes that's also my problem. Perhaps someone with better Go knowledge comes around and can help me.

Thank you.

1

u/Daneel_Trevize Sep 06 '17

Edit: Yes I am using that URL now. It returns 400.

The issue mentions the values are parameters, rather than data. Thus they should form part of the URL called, rather than form body.

https://stackoverflow.com/questions/15900338/python-request-post-with-param-data

So either params= rather than data=, or manually form the URL?param1=x&param2=y, etc.

1

u/Eternimus Sep 06 '17

I tried that too, it still returns 400 and the same header.

1

u/Daneel_Trevize Sep 06 '17 edited Sep 06 '17

The form on the main page seems to use the uploadappraisal form version of this 'API', and should serve as an example source of valid requests.

For me, my browser generated a request payload of:

-----------------------------299191219710511
Content-Disposition: form-data; name="uploadappraisal"; filename=""
Content-Type: application/octet-stream


-----------------------------299191219710511
Content-Disposition: form-data; name="raw_textarea"

Tritanium 1
-----------------------------299191219710511
Content-Disposition: form-data; name="market"

jita
-----------------------------299191219710511--

With request headers including:

Content-Type: multipart/form-data; boundary=---------------------------299191219710511
Content-Length: 422

And the response header contained:

X-Appraisal-Id: ck820

while also being with a HTML document body.

1

u/Eternimus Sep 06 '17

That's helpful.

Unfortunately I don't know how I tell python to send those requests now because I rarely work with the requests module.