最近迫于压力开发了个自动点击网站新闻的小工具,使用IDHTTP组件,但是运行之后没有效果
用IE浏览器点击http://10.72.1.215/jwywTj.do?infoId=###会记录浏览IP,并反馈“IP已被记录”,再次用IE浏览器点击会提示“IP已被记录,请勿重复点击”用IDHTTP.GET ('http://10.72.1.215/jwywTj.do?infoId=###')只会反馈“IP已被记录”,再次运行也是如此,不知道是怎么回事代码如下:
procedure TForm1.FormCreate(Sender: TObject);
 var
  reg:TPerlRegEx;
  List: TStringList;
begin
  reg:=TPerlRegEx.Create(nil);
  Memo1.Clear;
  Memo1.Lines.Add('此程序每小时自动点击一次,请最小化至任务栏。'+chr(13)+chr(10));
 try
    reg.Subject:=idhttp1.Get(edit1.Text);
 except
    Memo1.Lines.Add('网址读取超时......');
 end;
  reg.regex:='(?<=\b/\b)\d+(?=\b.html\b)';
  while reg.MatchAgain do
  begin
    Memo1.Lines.Add(FormatDateTime('c',now));
    Memo1.Lines.Add('获取警务要闻ID号:'+ reg.MatchedExpression +'');
    try
      idhttp1.Request.AcceptLanguage := 'zh-cn';
      idhttp1.Request.ContentType := 'application/x-www-form-urlencoded';
      idhttp1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)';
      Memo1.Lines.Add(Trim(idhttp1.Get('http://10.72.1.215/jwywTj.do?infoId='+ reg.MatchedExpression +'')));
      Memo1.Lines.Add('点击成功!'+chr(13)+chr(10));
    except
      Memo1.Lines.Add('网址读取超时......');
    end;
  end;
  List := TStringList.Create; //创建List
  if FileExists('log.txt') then
  begin
  List.LoadFromFile('log.txt');  //数据读入到List
  List.AddStrings(Memo1.Lines);  //追加Memo文本到List
  List.SaveToFile('log.txt');  //保存
  end
  else
  begin
  List.AddStrings(Memo1.Lines);
  List.SaveToFile('log.txt');
  end;
  List.Free;  //释放
  FreeAndNil(reg);   //释放
end;

解决方案 »

  1.   

    可能后端是用cookie来识别的吧。你get的时候附上cookie试试
      

  2.   

    感觉应该是COOKIE的问题,去试试看
      

  3.   

    这个用idhttp提交你得准确模拟提交的数据,包括http头和cookie
    先用浏览器提交,记录http头和cookie,再把这些头和cookie添加到idhttp里提交
      

  4.   

    统计点击量一般都是JS脚本,IdHttp不会执行JS的
      

  5.   

    四楼说得对,除了程序内部收集访问信息的,其它的第三方统计都是能过js收集的,也就是ajax,基本上除非用浏览器或浏览器组件访问,不然都没得统计数据的
      

  6.   

    IdHttp确实不会执行js脚本,解决这个问题可以用内嵌的WebBrowser,然后找出页面的提交或者你所要点击的按钮,直接用代码提交。//找页面元素
    class function TWBApi.GetElementObj(wb: TWebBrowser; index: integer; tagId: string; var obj: OleVariant): boolean;
    var
      doc: IHTMLDocument2;
      intf: IWebBrowser2;
      oleObj: OleVariant;
    begin
      result := false;
      try
        intf := wb.DefaultInterface;
        doc := intf.Document as IHTMLDocument2; // wb.Document
        if doc=nil then Exit;
        oleObj := doc.all.item(tagId,index) as IHTMLElement2;
        if TVarData(oleObj).VLongWord=0 then exit;
        obj := oleObj;
        result:= true;
      except
      end;
    end;//模拟点击
    if TWbApi.GetElementObj(wb,0,'submit',obj) then  obj.click;
      

  7.   

    禁止使用idhttp的 cookie即可