Answer the question
In order to leave comments, you need to log in
Python POST request getting wrong result?
Good afternoon, I'm trying to get data by POST request from the site , I looked at how the request is formed in the browser, after entering data into the filter and tried to write a request
import requests
test = 'elementID=find_unp_reestr&begin_between=1&end_between=10&unp=490822627'
r = requests.post("http://www.portal.nalog.gov.by/ngb/data/", data=test)
print(r.text)
python3 parser.py
<div id="null_error" onclick="ShowError('null')" class="error_message"><div style="width: 32px; height: 32px;"> </div><div style="width:640px; height:480px; overflow:auto;" ><font style="font-family: Arial; font-size: 12px; font-weight: bold;">Параметры элемента</font><br/><textarea style="width: 610px; height: 200px;" >{index=0, elementID=null, xslindex=0}</textarea><br /><font style="font-family: Arial; font-size: 12px; font-weight: bold;">Параметризованный запрос</font><br/><textarea style="width: 610px; height: 200px;" >null</textarea><br /><font style="font-family: Arial; font-size: 12px; font-weight: bold;">Результат выполнения запроса в XML виде</font><br/><textarea style="width: 610px; height: 200px;" ><?xml version="1.0" encoding="UTF-8"?><root></root></textarea><br /><font style="font-family: Arial; font-size: 12px; font-weight: bold;">Результат XML преобразования</font><br/><textarea style="width: 610px; height: 200px;" ></textarea><br /><br /></div></div>
<tbody><tr><td>490822627</td><td>Общество с ограниченной ответственностью "Джог и Ко"</td><td>23.04.2014</td><td>Абзац 6 п.1.1 Указа 488</td><td/><td/></tr></tbody>
Answer the question
In order to leave comments, you need to log in
data in post requests is passed in json
>>> import requests
>>> test = {'elementID': 'find_unp_reestr', 'begin_between': '1', 'end_between': '10', 'unp': '490822627'}
>>> r = requests.post("http://www.portal.nalog.gov.by/ngb/data/", data=test)
>>> r.text
'<tbody><tr><td>490822627</td><td>Общество с ограниченной ответственностью "Джог и Ко"</td><td>23.04.2014</td><td>Абзац 6 п.1.1 Указа 488</td><td/><td/></tr></tbody>'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question