1,593
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button1Click(Sender: TObject);
var
postList: TStrings;
Response: TStringStream;
begin;
Response := TStringStream.Create('');
postList := TStringList.Create;
try
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)';
postList.Add('__EVENTTARGET=');
postList.Add('__VIEWSTATE=/wEPDwUJLTI5NjAzODk2ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQULY2hrUmVtZW1iZXKHW0DW4nQrSrBHBomKrt3/MjtBLA==');
postList.Add('__EVENTVALIDATION=/wEWBQKE2u7lCQLyj/OQAgK3jsrkBALR55GJDgKC3IeGDO8x1Jd0k/hBY1a/6Yl9fTpP16ti');
postList.Add('tbUserName=用户名称');
postList.Add('tbPassword=用户密码');
postList.Add('chkRemember=');
postList.Add('btnLogin=登 录');
IdHTTP1.Post('http://passport.cnblogs.com/login.aspx',postList,Response);
finally
Memo1.Lines.Text := Utf8ToAnsi(Response.DataString);
Response.Free;
postList.Free;
end;
end;
<table width="725" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="89"><div align="right">起始日期:</div></td>
<td width="142">
<input type="text" id="strBeginTime" name="strBeginTime" style="border:1px solid #CCCCCC;" onClick="displayDatePicker('strBeginTime', this);" readonly="readonly" /> </td>
<td width="100"><div align="right">结束日期:</div></td>
<td width="142">
<input type="text" id="strEndTime" name="strEndTime" style="border:1px solid #CCCCCC;" onClick="displayDatePicker('strEndTime', this);" readonly="readonly" /> </td>
<td width="80"><input name="imageField" id="imageField" type="image" src="./images/m_query.gif" style="cursor:hand;filter:alpha(opacity=100)" onMouseDown="makevisible2(this,bao)" onMouseUp="makevisible2(this,bao) " onClick="javascript:queryDrivingList(1,'','');return false;">
<input type="hidden" name="fromWhere" value="allCard"> </td>
<td width="180" align="center"><font color="#FF0000">仅提供半年内的验证记录</font></td>
</tr>
</table>
Params := TStringList.Create;
with Params do
begin
Values['strBeginTime'] := '2011-03-01';
Values['strEndTime'] := '2011-06-01';
// Values['imageField'] := 'allCard';//主要是这里我不知道复什么值。。。。。。。。。。
Values['fromWhere'] := 'allCard';
end;
var
Doc: IHTMLDocument2;
userinputelement, pwdinputelement: ihtmlinputelement;
begin
// doc := WebBrowser1.document as ihtmldocument2;
doc := ihtmldocument2(WebBrowser1.document); //doc 定义有2种方式。上面的也可以
userinputelement := (doc.all.item('strBeginTime', 0) as ihtmlinputelement);
if userinputelement<> nil then
userinputelement.value := Trim(edit1.Text);
pwdinputelement := (doc.all.item('strEndTime', 0) as ihtmlinputelement);
if pwdinputelement<> nil then
pwdinputelement.value := Trim(edit2.Text);
try
WebBrowser1.OleObject.document.all.item('imageField').click;
except on E: Exception do
end;