?
Solved

getting Source Code

Posted on 2003-03-24
6
Medium Priority
?
245 Views
Last Modified: 2010-04-04
I want to get the source code of a website and put it into a textbox?

Any ideas?
0
Comment
Question by:doyuk
6 Comments
 
LVL 1

Accepted Solution

by:
Knighty earned 1000 total points
ID: 8199509
using the indy component(www.indyproject.or):
Memo1.Lines.Text:= IdHTTP.Get('url');

or using the Fastnet components:
NMHTTP1.Get('url');
Memo1.Text := NMHTTP1.Body;
0
 
LVL 1

Expert Comment

by:Knighty
ID: 8199516
0
 
LVL 1

Expert Comment

by:Knighty
ID: 8199612
or using the ICS component http://overbyte.delphicenter.com/ :
HttpCli1.URL := 'url';
HttpCli1.RcvdStream := TMemoryStream.Create;
HttpCli1.Get;
Memo1.Lines.LoadFromStream(HttpCli1.RcvdStream);
HttpCli1.RcvdStream.Destroy;
HttpCli1.RcvdStream := nil;
0
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!

 

Author Comment

by:doyuk
ID: 8201974
Thanks. It works...
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8202036
doyuk, you could also use this function to get rid of all those components:

{ uses WinInet }

function LoadFromURL(URL: String): String;
var
  hSession, hURL: hInternet;
  Buffer: array[0..1023] of Byte;
  BufferLength: DWord;
  Stream: TStringStream;
begin
  stream := TStringStream.Create('');
  Result := '';
  if (Pos('http://', LowerCase(url)) = 0) then URL := 'http://' + URL;
  hSession := InternetOpen('My_App;)', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  try
    hURL := InternetOpenURL(hSession, PChar(URL), nil, 0, INTERNET_FLAG_RELOAD, 0);
    try
      repeat
        InternetReadFile(hURL, @Buffer, 1024, BufferLength);
        Stream.WriteBuffer(Buffer, BufferLength);
        Application.ProcessMessages;
      until (BufferLength = 0);
      Result := Stream.DataString;
     finally
       InternetCloseHandle(hURL)
     end;
  finally
    InternetCloseHandle(hSession);
    Stream.free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Text := LoadFromURL('www.experts-exchange.com');
end;

Markus
0
 

Expert Comment

by:davizinx
ID: 23504838
very good, ty dude.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Integration Management Part 2
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question