Skip to content
Advertisement

How to POST JSON with data payload and header with Python Requests?

I am trying to do some scraping from websites using GET and POST methods, but now I am facing a new challenge.

I am trying to get data from a credit simulator, I found this portuguese site (https://www.bancomontepio.pt/particulares/credito/pessoal/credito-pessoal-online).

As far as I know, I need to use POST method, but I have to specify the data (the Amount value, the Term…). I usually do it by creating a dictionary structure but that is not working.

I’m kinda lost to be fair, maybe the problem is on the header…

Here is my code:

JavaScript

If i take off the .json(), I get the error Response [410].

The goal is to get the TAN or TAEG that change when term (“Prazo”) or amount (“Montante”) values change.

Any ideias?

[EDIT]

JavaScript

Now I’m getting a empty json()… Response 200 but I got this structure:

JavaScript

As far as I know, the status should be “OK” to get some info on the Result.

Cheers

Advertisement

Answer

Looks like you need to expand the payload to include more (all) of the parameters (including the cookies, specifically the ASP.NET_SessionId).

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement