最近迫于压力开发了个自动点击网站新闻的小工具,使用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;
用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;
解决方案 »
- delphi调用dll问题,专家救命,100分全部送上。
- 关于fastreport分组脚
- word,分页符小问题,高手救命 ,在线等!!!!!!!!!!
- 根据数组的元素创建表,谁懂?
- 如何在memo中自动滚到最下一行?
- 请问哪里有installshield express for delphi(full edition)下载,高分相送!!!
- 如何正确使用Query组件的delete方法?
- 怎么样获取断号!
- FileWrite的问题
- 在dll中的函数声明后加上stdcall后出地址空间错误,怎么解决阿?
- 请教一个关于事务的问题:一个窗口中update事务一直打开着,会有什么后果?
- 如何停止程序中正在执行的事件,不用break
先用浏览器提交,记录http头和cookie,再把这些头和cookie添加到idhttp里提交
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;