記錄一下我用過的模擬表單提交的乙個小例子,其實模擬表單提交原理很簡單,就是構建form表單中要提交的元素,通過web
client傳送到(post方法)目的頁面即可。
1、構建要提交的資料資訊(namevaluecollection)
/// /// 建立投票資訊
///
///
private namevaluecollection createvaluestovote()
return valuestovote;
}
2、提交資料,**如下
webclient client = new webclient();
byte byremoteinfo = client.uploadvalues("", "post", valuestovote);
string strresult = encoding.default.getstring(byremoteinfo);
if (strresult.contains("投票成功"))
模擬表單提交
httpclient模擬表單提交 建立httpclient物件,相當於建立瀏覽器。closeablehttpclient client httpclients.createdefault 建立請求方法,這裡以post方法為例。httppost httppost new httppost http l...
httpClient 模擬表單提交
httpclient 模擬表單提交 httpclient 模擬表單提交 public static void diandianadd int i 將表單的值放入postmethod中 postmethod.setrequestbody data 執行postmethod httpclient對於要求...
curl模擬post進行表單提交
先模擬乙個post提交 header content type text html charset utf 8 stuid 201301013 pwd 136 uri www.lihe.com lihe b.php 這裡換成你伺服器的位址 引數陣列 data array stuid stuid,pw...