Python code was giving "Error getting base data: Error parsing xmlsquery" - so problem was in xmlsquery.
I copied working xmlsquery from request in browser using DevTool (tab: Network) in Chrome/Firefox and compared (char-by-char) with response.request.body from Python code.
correct = "xmlquery=...from browser..."
wrong = response.request.body
for char_a, char_b in zip(correct, wrong):
if char_a != char_b:
print(char_a, char_b)
发布评论
评论(1)
我不知道您用来发送请求
但是,当我使用模块
请求
时,问题在查询中使+
在查询中。请求
将+
转换为%2B
,但服务器需要+
。它需要使用
urllib.parse
使用safe> safe =“+”
完整的工作代码:
在代码中您可以看到所有需要访问服务器的标头。
我如何找到
+
:Python代码正在给出
“错误获取基本数据:错误解析XMLSQUERY”
- 因此,问题在XMLSQUERY
中。我使用
devtool
(tab:network
)从浏览器中的请求中复制了xmlsquery,并将(Char-by-char)与
response.request.body
从Python代码进行了比较。I have no idea what you used to send request
but when I use module
requests
then problem makes+
in query.requests
converts+
to%2B
but server needs+
.It needs to manually convert data using
urllib.parse
withsafe="+"
Full working code:
In code you can see all needed headers to access server.
How I found
+
:Python code was giving
"Error getting base data: Error parsing xmlsquery"
- so problem was inxmlsquery
.I copied working xmlsquery from request in browser using
DevTool
(tab:Network
) inChrome
/Firefox
and compared (char-by-char) with
response.request.body
from Python code.