1,593
社区成员
发帖
与我相关
我的任务
分享
ts:=TStringList.Create;
try
for i := 0 to 1000 do
begin
RespData:=TStringStream.Create('');
try
IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko';
IdHTTP1.Get(url,RespData);
ts.Add(RespData.DataString);
finally
RespData.Free;
end;
end;
finally
ts.Free;
end;
ts:=TStringList.Create;
RespData:=TStringStream.Create('');
IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko';
try
for i := 0 to 1000 do
begin
try
IdHTTP1.Get(url,RespData);
ts.Add(RespData.DataString);
except
end;
end;
finally
ts.Free;
RespData.Free;
end;
修改过后, 你看效果是不是好多了 idhttp1.ProxyParams.ProxyServer:='111.11.11.11'; //代理IP
IdHTTP1.ProxyParams.ProxyPort:=8080;//代理端口
2.伪造IP, 这个比较难一点, 有时间可以研究一下EmbeddedWB1.Go(url);
然后才读取它的文本字符
所以不太明白你说的“要分步走”的意思? EmbeddedWB1.Go(url);
Memo1.Lines.Add(EmbeddedWB1.DocumentSourceText);
ts.Add(EmbeddedWB1.DocumentSourceText);
特意加了MEMO显示,但是执行后MEMO是空的,跟踪检查,EmbeddedWB1.DocumentSourceText显示如下图:
[/quote]
我前面说过,主要是因为URL经常访问不到 EmbeddedWB1.Go(url);
Memo1.Lines.Add(EmbeddedWB1.DocumentSourceText);
ts.Add(EmbeddedWB1.DocumentSourceText);
procedure TGlobHttpThread.Execute;
var
URLHTML: TStringStream;
begin
ConCount := ConCount + 1;
ResultStr := '';
Idhttp1 := TIdHTTP.Create(nil);
Idhttp1.HandleRedirects := True;
Idhttp1.Request.UserAgent := 'Mozilla/3.0 (compatible)';
Idhttp1.ProtocolVersion := pv1_1;
Idhttp1.ReadTimeout := 10000;
URLHTML := TStringStream.Create('', TEncoding.GetEncoding(936));
try
if SearchRes.NeedStream then
begin
Idhttp1.Get(GoURL, URLHTML);
ResultStr := URLHTML.DataString;
end
else
ResultStr := Idhttp1.Get(GoURL);
// sendmessage 或者 OnTerminate 进行处理
except
Idhttp1.Free;
ResultStr := '';
if ConCount < 3 then
Execute;
Exit;
end;
Idhttp1.Free;
URLHTML.Free;
end;
// MyList.Add(Tab.EWB.DocumentSource); // 源码
MyList.Add(Tab.EWB.DocumentSourceText); // 文本