Forum Moderators: coopster

Message Too Old, No Replies

Fetch result from Google Insight

Fetch result from Google Insight

         

irw10062

5:10 am on Jul 11, 2010 (gmt 0)

10+ Year Member



Hello,
i have file tes.html. Content code is bellow.
and i execute manual via browser like [localhost...] I got result fine.
but when i fetch using php code, it's result source only, i think caused output using javascript.

i fetch like this

$file = file_get_contents('http://localhost/tes.html');


i also tried using snoopy to fetch as text but got blank too


<html>
<body>
<script type="text/javascript" src="http://www.gmodules.com/ig/ifr?url=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Fgoogle_insightsforsearch_relatedsearches.xml&amp;up__results_type=TOP&amp;
up__property=empty&amp;up__search_term=Thing Thing 4&amp;up__location=empty&amp;up__category=0&amp;up__time_range=48-m&amp;up__max_results=20&amp;synd=open&amp;w=320 &amp;h=350&amp;lang=en-US&amp;
title=Google+Insights+for+Search&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>
</body>
</html>


the point is how to get as text from thats file like browser.

any help thanks

Readie

12:12 pm on Jul 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World irw10062.

As far as I know, you can't retrieve the end result of a javascript with PHP.

You could include the file on the page quite easily though:

include rtrim($_SERVER['DOCUMENT_ROOT'], "/") . '/tes.html';


Not sure if that's what you're after though.

Super_Chunk

4:55 pm on Jul 19, 2010 (gmt 0)

10+ Year Member



Not sure if this is what you're after but I use a different function to grab the contents of HTTP requests :

$file = implode("", file('http://localhost/tes.html'));

Maybe some more details would help.

Readie

6:25 pm on Jul 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$file = implode("", file('http://localhost/tes.html')); 

$file = file_get_contents('http://localhost/tes.html');


:)

irw10062

11:26 pm on Jul 19, 2010 (gmt 0)

10+ Year Member



i will test it

Super_Chunk

10:07 am on Jul 20, 2010 (gmt 0)

10+ Year Member



$file = implode("", file('http://localhost/tes.html'));


I believe I started using this method as a work-around for grabbing the contents of a file hosted on an external domain, without having to setup fopen wrappers etc.

That said it may just have been the setup I was using at the time meant the work-around was necessary ;)

Matthew1980

10:15 am on Jul 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

$file = file_get_contents('http://localhost/tes.html');

The point there is that this is the preferred way of getting a whole file read into a complete string without using arrays, so in essence in less memory intensive, at least that's the way I read it.

That and Readie corrected me earlier this month :) (Cheers readie btw!)

Cheers,
MRb

irw10062

10:37 am on Jul 20, 2010 (gmt 0)

10+ Year Member



that's script can grab & display it, but only return source javascript only, not result text from javascipt

Readie

5:47 pm on Jul 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



that's script can grab & display it, but only return source javascript only, not result text from javascipt

Yea it wouldn't, AFAIK there's no way to grab the JavaScript output with PHP (could be wrong here, if anyone knows different please let me know)

You could always just simulate the JS output with your own PHP script.

irw10062

5:53 pm on Jul 20, 2010 (gmt 0)

10+ Year Member



maybe u know another way to get it,
it's jsscript result keyword from google insight,
i want it grab automated and save to database