httplib java_httplib发布调用错误
我正在嘗試自動化幾個http請求,其中,我有以下從網絡捕獲的POST調用數據:
方法:POST請求標頭:
POST /cgi-bin/auto_dispatch.cgi HTTP / 1.1主機:10.226.45.6連接:keep-alive內容長度:244 Cache-Control:max-age = 0 Upgrade-Insecure-Requests:1 User-Agent:Mozilla / 5.0 (Windows NT 6.3; WOW64)AppleWebKit / 537.36(KHTML,與Gecko一樣)Chrome / 53.0.2785.143 Safari / 537.36內容類型:multipart / form-data; boundary = ---- WebKitFormBoundaryhwDXAifvLs48E95A接受:text / html,application / xhtml xml,application / xml; q = 0.9,image / webp,/; q = 0.8 Referer:http://10.226.45.6/auto_dispatch.html Accept-Encoding:gzip,deflate Accept-Language:en -US,en; q = 0.8,kn; q = 0.6 Cookie:TWIKISID = dce9a6aa10e33b708f5bbc2912f781ab
負載:
------ WebKitFormBoundaryhwDXAifvLs48E95A Content-Disposition:form-data; NAME = “任務id”
123 ------ WebKitFormBoundaryhwDXAifvLs48E95A Content-Disposition:form-data; NAME = “提交”
提交表格------ WebKitFormBoundaryhwDXAifvLs48E95A--
我的腳本如下:
import httplib, urllib
def printText(txt):
lines = txt.split('\n')
for line in lines:
print line.strip()
params = urllib.urlencode({'@taskid': 12524, '@Submit': 'Submit Form'})
headers = {"Content-type": "multipart/form-data", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"}
conn = httplib.HTTPConnection("10.226.45.6", 80)
conn.request("POST", "auto_dispatch.html", params, headers)
response = conn.getresponse()
print response.status, response.reason
printText (response.read())
conn.close()
我收到以下錯誤:
400錯誤請求400錯誤請求錯誤請求您的瀏覽器發送了此服務器無法理解的請求 .
請幫我形成一個合適的要求 .
總結
以上是生活随笔為你收集整理的httplib java_httplib发布调用错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python自动化控制设备有限公司_华为
- 下一篇: kafka 怎么样连接图形化界面_从零开