matejo
asked on
How to get the source of http document as fast as possible?
Hi!
This site looks great to me, so I have registered allready! :-)
My problem is:
I want to get a html source of web document, but ONLY this. Using WebBrowser causes me to wait until the document will be diplayed. And I don't need it to be displayed.
In Delphi5 I use this function:
function TForm1.page(url: string): string;
var
Doc: IHTMLDocument2;
Flags : OLEVariant;
begin
Flags := 14; // 2+4+8 = do not use cache and history
WebBrowser1.Navigate(adres , Flags);
repeat
Application.ProcessMessage s;
until not WebBrowser1.Busy;
Doc := WebBrowser1.Document AS IHTMLDocument2;
if Doc <> nil then
page := (Doc.Body AS IHtmlElement).innerHTML;
end;
so I have a source of document using:
source := page(http://www.some.site.on.the.net');
I am sure there is some tricky way to obtain only a source, without displaying the whole www site.
Maybe I can use somehow RequestDoc method?
Anyway - I have no idea how to do this.
Please, can you help me?
Best regards
This site looks great to me, so I have registered allready! :-)
My problem is:
I want to get a html source of web document, but ONLY this. Using WebBrowser causes me to wait until the document will be diplayed. And I don't need it to be displayed.
In Delphi5 I use this function:
function TForm1.page(url: string): string;
var
Doc: IHTMLDocument2;
Flags : OLEVariant;
begin
Flags := 14; // 2+4+8 = do not use cache and history
WebBrowser1.Navigate(adres
repeat
Application.ProcessMessage
until not WebBrowser1.Busy;
Doc := WebBrowser1.Document AS IHTMLDocument2;
if Doc <> nil then
page := (Doc.Body AS IHtmlElement).innerHTML;
end;
so I have a source of document using:
source := page(http://www.some.site.on.the.net');
I am sure there is some tricky way to obtain only a source, without displaying the whole www site.
Maybe I can use somehow RequestDoc method?
Anyway - I have no idea how to do this.
Please, can you help me?
Best regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Tvigep,
actually I found a few hours ago one of the solution, that is:
NMHTTP1.Body;
It is VERY easy, just like yours. :-)
But I am actually testing it.
Your solution will also be tested. I'll chceck it.
Thanky you all very much. The best solution (if it won't be mine) will be rewarded! :)
Best regards
actually I found a few hours ago one of the solution, that is:
NMHTTP1.Body;
It is VERY easy, just like yours. :-)
But I am actually testing it.
Your solution will also be tested. I'll chceck it.
Thanky you all very much. The best solution (if it won't be mine) will be rewarded! :)
Best regards
ASKER
All right then,
my sloution works very well. Hmmm, it is not right that I got an answer from myself... ;-)
The code looks like this:
uses NMHttp
...
NMHTTP1.Get('http://www.some.site.on.the.net);
st := NMHTTP1.Body;
...
Very easy, indeed.
========================== ========== ========== ======
========================== ========== ========== ======
-*-*-*-*-*-*-*-*-*-*-*-*-* -*-*-*-*-* -*
But now - ANOTHER QUESTION!!!
-*-*-*-*-*-*-*-*-*-*-*-*-* -*-*-*-*-* -*
Is it possible (all the time not using WebBrowser) to get HTTP Body, if the site won't allow me to reach the HTML document without a Cookie?
In other words: I receive a Cookie, which, using "normal" web browser (like IE or Netscape), allow me to surf on the site. But without the Cookie - nothing. Can I inform www.site that I have allready received a Cookie? How Can I do this? Is it possible at all?
I rise the amount of point to 75 (all I have :) ) since it looks more complicated.
Best regards!
my sloution works very well. Hmmm, it is not right that I got an answer from myself... ;-)
The code looks like this:
uses NMHttp
...
NMHTTP1.Get('http://www.some.site.on.the.net);
st := NMHTTP1.Body;
...
Very easy, indeed.
==========================
==========================
-*-*-*-*-*-*-*-*-*-*-*-*-*
But now - ANOTHER QUESTION!!!
-*-*-*-*-*-*-*-*-*-*-*-*-*
Is it possible (all the time not using WebBrowser) to get HTTP Body, if the site won't allow me to reach the HTML document without a Cookie?
In other words: I receive a Cookie, which, using "normal" web browser (like IE or Netscape), allow me to surf on the site. But without the Cookie - nothing. Can I inform www.site that I have allready received a Cookie? How Can I do this? Is it possible at all?
I rise the amount of point to 75 (all I have :) ) since it looks more complicated.
Best regards!
You can set the cookie password and everything you need like this (replace'' by the relevant string :
With NMHttp.HeaderInfo do
Begin
Cookie := '';
LocalMailAddress := '';
LocalProgram := '';
Referer := '';
UserID := '';
Password := '';
End;
With NMHttp.HeaderInfo do
Begin
Cookie := '';
LocalMailAddress := '';
LocalProgram := '';
Referer := '';
UserID := '';
Password := '';
End;
I forgot to tell that to read a cookie send to you by the web site you have to read the header that will saved in the file specified by NMHttp.Header
ASKER
Ha ha ha, I found it too in a help. :D :D
Ok, if it'll work, you get your points! :)
Best regards!
Ok, if it'll work, you get your points! :)
Best regards!
matejo:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
Hi!
No comment has been added lately and this question is therefore classified abandoned.
If asker wishes to close the question, then refer to
https://www.experts-exchange.com/help/closing.jsp
Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
Split between Soko and Tvigep
Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
...Snehanshu
EE Cleanup Volunteer
No comment has been added lately and this question is therefore classified abandoned.
If asker wishes to close the question, then refer to
https://www.experts-exchange.com/help/closing.jsp
Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
Split between Soko and Tvigep
Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
...Snehanshu
EE Cleanup Volunteer
ASKER
actually I found a few hours ago one of the solution, that is:
NMHTTP1.Body;
It is VERY easy, just like yours. :-)
But I am actually testing it.
Your solution will also be tested. I'll chceck it.
Thanky you all very much. The best solution (if it won't be mine) will be rewarded! :)
Best regards