shiverieskwok
shiverieskwok
2019-02-19 23:51

Request form-data post

  • python

爬取目标:路由器WEB界面

Formdata:
Form_data = {
"SharedTmpSid": new_shareid,
"is_advanced": "0",
"dns": "0",
"userIdent": id,
"page": "globalsettings-index.xml",
"$db$.admin.0.biboAdmDomainName": "",
"$db$.admin.0.biboAdmWINS1": "172.31.7.41",
"$db$.admin.0.biboAdmWINS2": "172.31.7.50",
"$db$.ipDns.0.ipDnsUsePosCache": "2",
"$db$.ipDns.0.ipDnsUseNegCache": "2",
"$db$.ipDns.0.ipDnsMaxCacheSize": "100",
"$db$.ipDns.0.ipDnsPositiveTtl": "86400",
"$db$.ipDns.0.ipDnsNegativeTtl": "300",
"$db$.ipDns.0.ipDnsDefaultIfIndex": "-1",
"$db$.ipDns.0.ipDnsDhcpAssign": "2",
"$db$.ipDns.0.ipDnsIpcpAssign": "3",
"BUTTON_APPLY": "OK",
"replace": "inline",
}

脚本如下:
def revise_Dns(id,new_shareid):
url="http://ip/esi/912100/esi.cgi"
r.headers.update({"Content-Type": "application/x-www-form-urlencoded"})
r.headers.update({"Referer": "http://ip/esi/912100/esi.cgi?page=index.xml&sessionID={}".format(id)})
r.headers.update({"X-Requested-With": "XMLHttpRequest"})
Post = {
"SharedTmpSid": new_shareid,
"is_advanced": "0",
"dns": "0",
"userIdent": id,
"page": "globalsettings-index.xml",
"$db$.admin.0.biboAdmDomainName": "",
"$db$.admin.0.biboAdmWINS1": "172.31.7.41",
"$db$.admin.0.biboAdmWINS2": "172.31.7.50",
"$db$.ipDns.0.ipDnsUsePosCache": "2",
"$db$.ipDns.0.ipDnsUseNegCache": "2",
"$db$.ipDns.0.ipDnsMaxCacheSize": "100",
"$db$.ipDns.0.ipDnsPositiveTtl": "86400",
"$db$.ipDns.0.ipDnsNegativeTtl": "300",
"$db$.ipDns.0.ipDnsDefaultIfIndex": "-1",
"$db$.ipDns.0.ipDnsDhcpAssign": "2",
"$db$.ipDns.0.ipDnsIpcpAssign": "3",
"BUTTON_APPLY": "OK",
"replace": "inline",
}
payload={
"userIdent": id,
"replace": "inline",
"cacheAvoider": "dummy"
}
# content_encoded=urlencode(Post)
pt=r.post(url,headers=header,data=Post,params=payload)
print pt.text

出来的结果总是提示页面无法找到,如下:

globalsettings-index.xml Not Found

但是返回的状态码是200

请各路大神指点一下,谢谢

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答