3
Contributors
14
Replies
15
Views
8 Years
Discussion Span
Last Post by zegames
0

Of course, if you weren't trying to disguise yourself as a user-agent, you could do this instead.

<?php
$url = 'http://www.google.com';
print file_get_contents( $url ); 
?>

Cheers

Same problem, will get page without the search block result.

0

I'm not getting the nested-body content of the Gamespot page using cURL (probably relative linked iframe) but it appears your PHP script is working in general.

If you are trying to figure out how to return these results to a JavaScript function using Ajax and/or get the $url passed in via Ajax then you need only change your static $url at the top of the page with something like this...

if ( $url = $_POST['url'] ) {
  // perform cURL code here
}

...and that should take care of the server-side end of the equation.

If you are new to JavaScript Ajax methods, it is a big topic for a single thread and is very well documented in many tutorials all over the web and likely on this site too -- I would search around.

Otherwise I am misunderstanding the problem you are having.

Good luck

0

Sorry, but I think you don't understand what I need.

I just want grabble the search result block of gamespot, my example script is only to show for you guys my problem with blank issue because gamespot change the results recently to ajax driven.

If you can get correctly the page bellow by php, show how to.

http://www.gamespot.com/search.html?type=11&stype=all&qs=grid

Thank you!

0

Sorry, but I think you don't understand what I need.

I just want grabble the search result block of gamespot, my example script is only to show for you guys my problem with blank issue because gamespot change the results recently to ajax driven.

If you can get correctly the page bellow by php, show how to.

http://www.gamespot.com/search.html?type=11&stype=all&qs=grid

Thank you!

You are going to have to go to gamespot and pull their javascript apart to find the url that their ajax call is going to because I'm sure that it is pulled in after the initial load time.

0

Okay, I may be mistaken, but I don't believe this can be done -- or at least I have no idea how to do it.

Sorry

0

It appears the problem you are having with this approach is what Rob is referring to in the above post. You are getting the contents of the page while the Ajax on that page is still pulling results from their database. Then they load the search results but you've already loaded the page locally without those results.

Ajax has protection (sandbox security) around talking to scripts not on its own server, so I suspect that even if you get access to their Ajax javascript page, you would still not be able to communicate with it.

0

It appears the problem you are having with this approach is what Rob is referring to in the above post. You are getting the contents of the page while the Ajax on that page is still pulling results from their database. Then they load the search results but you've already loaded the page locally without those results.

Ajax has protection (sandbox security) around talking to scripts not on its own server, so I suspect that even if you get access to their Ajax javascript page, you would still not be able to communicate with it.

I know that I have mine shutdown tight, they only allow requests from within my docroot.

0

But then again, it depends on the security within that server side script. For instance, my ajax calls reference a php file with post or get variables, so I can still post to this same document with just a form. But the key is that my file does not allow any post or get requests to run it if that request is not made from within my docroot, they may have chosen not to be that secure, the only way to tell is to try.

0

http://www.gamespot.com/search.html?qs=test is not ajax.

Honestly, I didn't spend a ton of time digging through the messy source code on that pge ... but if you use PHP to call that page with a query string, the query shows up in the search box but with no results in the body field. So I'm guessing the search results are somehow restricted from off site access...which makes me think Ajax.

I'm open to other options though.

:-)

0

Hi again guys,

Here my final test working code:

<? 

$curl = curl_init(); 

$url = 'http://www.gamespot.com/pages/search/search_ajax.php?q=grid&type=game&offset=0&tags_only=false&sort=rank'; 

curl_setopt($curl, CURLOPT_URL, $url); 
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/json","X-Requested-With: XMLHttpRequest")); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 

$result = curl_exec($curl); 

echo $result; 

?>

The solution? just see the headers that I set.

Cya

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.