Even if you define the url properly by assigning the given URL:
import requests
url = "https://www.upiqrcode.com/iban-generator/de/germany"
datas = {}
GetInfo = requests.post(url, data=datas)
decodeResponse = GetInfo.content.decode("utf-8")
print(decodeResponse)
You would end up getting HTML as response, which correctly prints on console.
Record the form-submission and watch POST request in browser
Instead, figure out how and where the form-data is POSTed. Do this by opening the browsers Developer Console (usually F12) and viewing the Network tab, before clicking submit button (here "Calculate") on the form.
![Firefox Network Monitor to show POST request]()
You can even right-click on the request there an Copy > as CURL. Then paste that in a text-editor or on the command-line to reproduce.
curl 'https://www.upiqrcode.com/get-iban-number' \
-H 'User-Agent: Mozilla/0.0 (OS) Gecko/20210808 Firefox/0.0' \
-H 'Accept: text/html, */*; q=0.01' \
-H 'Accept-Language: en-US,en;q=0.5' --compressed \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Origin: https://www.upiqrcode.com' \
-H 'Connection: keep-alive' \
-H 'Referer: https://www.upiqrcode.com/iban-generator/de/germany' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Sec-GPC: 1' \
--data-raw 'country=DE&bank=37040044&branch=&account=0532013000&ip=0.0.0.0'
Note: I have broken into several lines for readability (thus the \ at line ends). For privacy protection I have anonymized data like User-Agent and IP in the request above.
Even when anonymized like this, the request sent via cURL on the command-line, you get a response (HTML snippet) with the expected IBAN:
<h4 class="text-center text-success">IBAN Electronic Format :DE89370400440532013000</h4><h4 class="text-center text-success">IBAN Paper Format :DE89 3704 0044 0532 0130 00 </h4>
Reproduce in Python
Now you can rebuild this POST-request in Python.
What we need is:
- some request-headers like
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
- the posted data:
'country=DE&bank=37040044&branch=&account=0532013000&ip=0.0.0.0'