Python POST:提交按钮表单

时间:2013-09-04 18:52:17

标签: python post httprequest ntlm

我正在使用具有NTLM身份验证支持的Python Requests

import requests
from requests_ntlm import HttpNtlmAuth


url = 'http://ManufacturingRequests/AllItems.aspx'
username = 'domain\user'
password = 'pass'

r = requests.get(url,auth=HttpNtlmAuth(username,password))
print r.text.encode('utf-8')

我正在使用的网址的HTML看起来像

<input type="button"
   name="Button" 
   value="OK"
   onclick="if (!PreSaveItem()) return false;WebForm_DoPostBackWithOptions(new   WebForm_PostBackOptions(&quot;Button;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))" 
   id="ctl00_PlaceHolderMain_g_6b9c5d27_394f_4ab7_9c54_1b7507fd14a1_savebutton1_ctl00_diidIOS    veItem"
   accesskey="O" 
   class="ms-ButtonHeightWidth" 
   target="_self"
>

如何点击按钮(提交按钮表格)?

toPost = {'Button': 'submitForm'}
r = requests.post(url, data=toPost)

0 个答案:

没有答案