思科的Python命令查找工具解析器

时间:2015-05-24 05:13:32

标签: javascript python html cisco

我想创建一个连接到Cisco命令查找工具站点的python脚本,使用我的凭据进行身份验证,填充必要的字段并搜索我需要的所有命令并提供解释。思科的网站看起来像这样:

我能够通过使用以下脚本来达到这一点:

import requests

USERNAME = 'username' 
PASSWORD = 'password'

DATAURL = 'https://tools.cisco.com/Support/CLILookup/cltSearchAction.do'

session = requests.session()

req_headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}

formdata = {
    'userid': USERNAME,
    'password': PASSWORD,
    'login-button' : 'Login'
}

# Authenticate
r = session.post(DATAURL, data=formdata, headers=req_headers, allow_redirects=True)
print r.headers
print r.status_code

此后,脚本需要相应地填充下拉菜单并显示结果。我使用chrome的检测工具来获取必要的信息。我发现当用户填充下拉字段并按下GET请求下面的提交按钮chrome发送到服务器时:

https://tools.cisco.com/Support/CLILookup/cltSearchAction.do?AT=getCommandList&IndexId=1&IndexOptionId=1473&SearchPhrase=&PageNumber=0

不幸的是,这个链接并不适用于它自己,所以我需要帮助来解决这个问题,并获得理想的结果。

非常感谢。

0 个答案:

没有答案