Page 1 of 1

On load type function using PHP?

Posted: Sat Jun 06, 2009 6:39 am
by geny
[Urgent]
Hi ,
I am trying to extract text from a website using file_get_contents('url'),no issues with that.
Thing is that I am not getting expected output of it..And the reason I see is that ,if the url is generally opened,first home page flashes and while the page is still loading another/final set of information is displayed. So,final information is only displayed once the page is finally loaded.While the file_get_contents() function returns initial text/content of the website...
What all can be done,such that file_get_contents('url') extracts data only and ONLY after page stops loading and is fully loaded. I think a function like onpageload etc does not exist in PHP,not sure.. Please guide me with tips/code snippets/links etc .. Any help will be greatly appreciated.
In short,I want the content of website,only after its fully loaded and want the file_get_contents('url') execute only after 'url' is fully loaded. Thanks
Thanks a lot.Please let me know,if any part of the problem statement remains unclear.Thanks again..
--
$html_in_site = file_get_contents('url');
sleep(10);
echo $html_in_site;
--

Re: On load type function using PHP?

Posted: Sat Jun 06, 2009 8:29 am
by onion2k
You'll have to work out what the script in the page is loading (with some sort of AJAX I imagine) and load that instead. You can't run the script that the page is running in your PHP. I expect it'll be easy enough if there's one thing happening, but if it's more dynamic it'll pretty close to impossible.

Alternatively, you could use exec() with some shell scripting to make a browser on the server load the page and then pass the rendered content to PHP... that'd be tricky though, especially if you don't have complete control of the hosting environment.

Re: On load type function using PHP?

Posted: Sun Jun 07, 2009 12:54 am
by geny
Thanks for reply.Please see this url,where I need help ->
http://data.giub.uni-bonn.de/openroutes ... st&lang=de
You will notice that initially on the left pane,there is text "First Europe wide " in the lower half of left pane,and after a second or 2 a Routing description shows up, starting with "Route-Instruction" etc.Now,I want to grab this Route-Instruction and data/text below it..
Is this Ajax or something,Please guide/help ,,as in how can I grab this piece of text ..
Thanks a lot in advance.
Regards,
G

Re: On load type function using PHP?

Posted: Sun Jun 07, 2009 2:09 am
by onion2k
Definitely looks like it's being loaded in via AJAX, or some sort of scripting. You'll have to reverse engineer the app to figure out exactly what it's doing. It's a big job.