W
WilliamJia
Unregistered / Unconfirmed
GUEST, unregistred user!
用Indy控件取以下URL的源文件时会出现重定向错误(Http/1.1 301),请问是什么原因,该如何解决?
URL:= 'http://www.nytimes.com/2006/07/03/technology/03lulu.html'
源码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP,strUtils, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
IdHTTP1: TIdHTTP;
Edit1: TEdit;
WebBrowser1: TWebBrowser;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
url: String;
html: String;
TmpStream: TStringStream;
begin
TmpStream := TStringStream.Create('');
url := 'http://www.nytimes.com/2006/07/03/technology/03lulu.html';
//url := 'http://www.sciam.com/article.cfm?chanID=sa003&articleID=0006B51F-9073-14A5-907383414B7F0000';
idHttp1.Head(url);
//WebBrowser1.Navigate(url);
Memo1.Lines.Add(IdHttp1.Request.ContentType);
end;
end.
URL:= 'http://www.nytimes.com/2006/07/03/technology/03lulu.html'
源码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP,strUtils, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
IdHTTP1: TIdHTTP;
Edit1: TEdit;
WebBrowser1: TWebBrowser;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
url: String;
html: String;
TmpStream: TStringStream;
begin
TmpStream := TStringStream.Create('');
url := 'http://www.nytimes.com/2006/07/03/technology/03lulu.html';
//url := 'http://www.sciam.com/article.cfm?chanID=sa003&articleID=0006B51F-9073-14A5-907383414B7F0000';
idHttp1.Head(url);
//WebBrowser1.Navigate(url);
Memo1.Lines.Add(IdHttp1.Request.ContentType);
end;
end.