Delphi中idHttp获取网页源文件
生活随笔
收集整理的這篇文章主要介紹了
Delphi中idHttp获取网页源文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
procedure TForm1.Button1Click(Sender: TObject);
var
? pageStr: string;
begin
? with IdHTTP1.Request do begin
??? IdHTTP1.HandleRedirects := true; //使用Idhttp.Post時,出現 HTTP/1.1 302 FOUND 錯誤,地址自動轉向。
??? ContentType := 'application/x-www-form-urlencoded';
??? UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)';
? end;
? try
??? pageStr:=IdHttp1.Get('http://www.renyuansoft.com');
? except
??? Showmessage('Network Error!');
??? Exit;
? end;
? Memo1.text := pageStr;
?
?end;
var
? pageStr: string;
begin
? with IdHTTP1.Request do begin
??? IdHTTP1.HandleRedirects := true; //使用Idhttp.Post時,出現 HTTP/1.1 302 FOUND 錯誤,地址自動轉向。
??? ContentType := 'application/x-www-form-urlencoded';
??? UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)';
? end;
? try
??? pageStr:=IdHttp1.Get('http://www.renyuansoft.com');
? except
??? Showmessage('Network Error!');
??? Exit;
? end;
? Memo1.text := pageStr;
?
?end;
總結
以上是生活随笔為你收集整理的Delphi中idHttp获取网页源文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php递归算法计算n 介乘,递归算法示例
- 下一篇: 解决Xcode 13.2 不兼容 ios