从网上找了一个模拟登录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;

解决方案 »

  1.   

    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;
    这个是使用TWebBrowser来模拟的。这个经过测试是可以通过的。
      

  2.   

    各个网站的http头信息都有可能不一样的,你用抓包工具,看看你提交的网站的各种信息
      

  3.   

    必须检测出那些
    用户信息是否完整或者是否相对应>>>>>>>>>>
      

  4.   

    手工在网站上面提交一次查询。在你的脚本代码中打印出 imageField的值。大约好像应该是什么坐标位置。x y之类的值(记得是这样的)把这个值放到你的程序中去就行了。
      

  5.   

    最好先抓下页面读最新的POST的INPUT hide中的信息。
      

  6.   

    用chrome浏览器 它自带开发工具 我现在都用它查看网页封包
    快捷键是ctrl+shift+I