how to get post request on this website? https://www.upiqrcode.com/iban-generator/de/germany
Question:
how to get post request on this website?
here I have trouble getting post requests such as urls and post data, because I use a smart phone so I can’t get it, anyone can get it, the url and post data are okay.
this is the website
https://www.upiqrcode.com/iban-generator/de/germany
I want the data section to be filled in like this when on the website
Select Country: Germany
Bank Code (8 Digits .i.e. 37040044 ): 37040044
Bank Account No. ( 10 digits i.e. 0532013000): 0532013034
import requests
url = ""
datas = {}
GetInfo = requests.post(url, data=datas)
decodeResponse = GetInfo.content.decode("utf-8")
print(decodeResponse)
Answers:
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.
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'
Please refer Mr.hc_dev asnwer to know how i got URL
import requests
url = "https://www.upiqrcode.com/get-iban-number"
replace_with_your_ip = ""
datas = {
"country":"DE",
"bank":"37040044",
"account":"0532013034",
"ip":replace_with_your_ip,
}
GetInfo = requests.post(url, data=datas)
decodeResponse = GetInfo.content.decode("utf-8")
print(decodeResponse)
To remove HTML content
import re
def remove_tags(text):
comp = re.compile(r'<[^>]+>')
return comp.sub('', text)
print(remove_tags(decodeResponse))
Or with BeautifulSoup
from bs4 import BeautifulSoup
soup = BeautifulSoup(decodeResponse,"html.parser")
for i in soup.find_all("h4"):
print(i.text)
O/P
IBAN Electronic Format :___ Paper Format :___
One can generate IBAN Numbers by using GFINCO IBAN Generator API. Please check the following link for generating IBAN Numbers of Germany:
https://www.gfinco.com/iban-calculation-api/de/germany
You can also generate IBAN Numbers of IBAN Countries. Please check following link:
how to get post request on this website?
here I have trouble getting post requests such as urls and post data, because I use a smart phone so I can’t get it, anyone can get it, the url and post data are okay.
this is the website
https://www.upiqrcode.com/iban-generator/de/germany
I want the data section to be filled in like this when on the website
Select Country: Germany
Bank Code (8 Digits .i.e. 37040044 ): 37040044
Bank Account No. ( 10 digits i.e. 0532013000): 0532013034
import requests
url = ""
datas = {}
GetInfo = requests.post(url, data=datas)
decodeResponse = GetInfo.content.decode("utf-8")
print(decodeResponse)
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.
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'
Please refer Mr.hc_dev asnwer to know how i got URL
import requests
url = "https://www.upiqrcode.com/get-iban-number"
replace_with_your_ip = ""
datas = {
"country":"DE",
"bank":"37040044",
"account":"0532013034",
"ip":replace_with_your_ip,
}
GetInfo = requests.post(url, data=datas)
decodeResponse = GetInfo.content.decode("utf-8")
print(decodeResponse)
To remove HTML content
import re
def remove_tags(text):
comp = re.compile(r'<[^>]+>')
return comp.sub('', text)
print(remove_tags(decodeResponse))
Or with BeautifulSoup
from bs4 import BeautifulSoup
soup = BeautifulSoup(decodeResponse,"html.parser")
for i in soup.find_all("h4"):
print(i.text)
O/P
IBAN Electronic Format :___ Paper Format :___
One can generate IBAN Numbers by using GFINCO IBAN Generator API. Please check the following link for generating IBAN Numbers of Germany:
https://www.gfinco.com/iban-calculation-api/de/germany
You can also generate IBAN Numbers of IBAN Countries. Please check following link: