使用XPATH的Python POST请求

时间:2019-04-17 05:14:37

标签: python xml post python-requests

请帮助我将网络浏览器中的工作URL请求转换为python请求模块可执行文件请求。

我正在使用的浏览器请求网址:

https://192.168.100.25/api?type=config&action=set&xpath=/config/devices/entry[@name=%27localhost.localdomain%27]/network/interface/ethernet/entry[@name=%27ethernet1/1%27]/layer3/ip&element=%3Centry%20name=%279.6.6.6/24%27/%3E

此设备基本上接受XML格式的Rest API调用。请帮助我,将此转换为python请求POST请求。

1 个答案:

答案 0 :(得分:0)

我找到了一种处理Python请求的方法:

  

url ='''https://192.168.100.25/api?   type = config&action = set&xpath = / config / devices&element ='''

     

out = requests.post(URL,verify = False,auth = HTTPBasicAuth(用户名,密码))

这正在工作。

请让我知道是否有更简单,更适当的方法来完成此操作。