从网上找了一个模拟登录csdn的博客园 代码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;
但是运用到我自己的网址去模拟用户点击查询 则不行呢?
我的网址html部分代码 <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>
上面的imageField 其实是一张图片(查询)。
关键是这个imageField 没有value值,我不知道如何去复制。 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
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;
但是运用到我自己的网址去模拟用户点击查询 则不行呢?
我的网址html部分代码 <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>
上面的imageField 其实是一张图片(查询)。
关键是这个imageField 没有value值,我不知道如何去复制。 Params := TStringList.Create;
with Params do
begin Values['strBeginTime'] := '2011-03-01';
Values['strEndTime'] := '2011-06-01';
// Values['imageField'] := 'allCard';//主要是这里我不知道复什么值。
Values['fromWhere'] := 'allCard';
end;
解决方案 »
- 在一定条件下点Treeview1前端+号,不允许展开
- 编译无法通过!出现错误NOT enough actual parameters?
- 如何在一个button 事件中判断是否已经选取dbgrid中的任何一条记录,如果没有选择则提示错误信息?
- COM+组件开发问题?
- delphi窗口自动关闭
- 在delphi中控制word, 插入一张图片,再写几个蓝底白字的汉字,使文字在图片右边且垂直方向上居中。谁能实现此功能(或提供相关资料),10
- 我打开一个TXT文本,想读取其中的内容,只有一行内容,可fileread怎么读不出内容,
- 关于EhlibV1.56的问题和DBGRID序号问题?
- 关于DELPHI和SQL:表格记录
- 控件开发:继承问题?
- 如何截获“获取硬盘物理序列号”的API
- 日期非法
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;
这个是使用TWebBrowser来模拟的。这个经过测试是可以通过的。
用户信息是否完整或者是否相对应>>>>>>>>>>
快捷键是ctrl+shift+I