• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1327
  • Last Modified:

INDY HTTP/1.1 501 Method not implemented

Hi,

I tried to download a web page from the internet using IdHTTP. Using the following code:

procedure TForm1.Button2Click(Sender: TObject);
var
 Link, HTML: String;

begin
try
  idHTTP1.Request.Accept:='text/html, */*';
  idHTTP1.Request.Host:='http://www.xxxxx.com';
  IdIOHandlerStream1.Host := idHTTP1.Request.Host;
  idHTTP1.Request.ContentType:='text/html';
  Link := Edit1.Text;
  // Edit1.Text= http://www.xxxxx.com/public/Group%One/default.aspx?section=yresults
  Memo2.Lines.Text := IdHTTP1.Get(Link);
  Memo2.Lines.SaveToFile('c:\tst.html');
EXCEPT
    ShowMessage('Could not load the file.');
END;

Open in new window


the url contains default.aspx?section=yresults

When I run the program it show me this error message
"HTTP/1.1 501 Method not implemented"


Can Anyone Help me to download a webpage the contains this extension default.aspx?section=yresults ?

Thank you
0
MissManal
Asked:
MissManal
1 Solution
 
MorphorCommented:
This error usually occurs when you're trying to access an old server... (link)
Nonetheless accessing the code via TWebBrowser should be always working...

//----------------------- Saves the source code via TWebBrowser --------------------
procedure WB_SaveAs_HTML(WB : TWebBrowser; const FileName : string) ;
var
  PersistStream: IPersistStreamInit;
  Stream: IStream;
  FileStream: TFileStream;
begin
  if not Assigned(WB.Document) then
  begin
    ShowMessage('Document not loaded!') ;
    Exit;
  end;
  PersistStream := WB.Document as IPersistStreamInit;
  FileStream := TFileStream.Create(FileName, fmCreate) ;
  try
    Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
    if Failed(PersistStream.Save(Stream, True)) then ShowMessage('SaveAs HTML fail!') ;
  finally
    FileStream.Free;
  end;
end;
//-------------- TFORM code ------------------------
procedure TForm1.Button1Click(Sender: TObject);
begin
    WebBrowser1.Navigate(Edit1.Text);
end;

procedure TForm1.WebBrowser1NavigateComplete2(ASender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  WB_SaveAs_HTML(WebBrowser1, Path);
end;

Open in new window

0
 
MissManalAuthor Commented:
:)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now