1. Open IE and go to www.yandex.com
2. Type some text to search for.
3. The web site changes, and yes, the URL changes one time to show the results page.
4. But this is the only change. If you scroll down to the bottom of the page and click to advance to another page of results, the URL never changes but the results content expands.
5. Now, after you have clicked to show more results a few times so that you have about one hundred search results, and click in the IE browser to view the HTML source code, and save that source into an html page and load that content back into the browser, you will only see the first page of search results and the button to see more content is not displayed.

So this makes it difficult to use this search results programatically unless you know this trick.

Replies To: How does Yandex do its trick?

Re: How does Yandex do its trick?

Posted 23 November 2012 - 03:14 AM

Hello there,

For some reason I cannot see the page you linked, not sure if it's down or the firewall I am behind is being overly strict today, but from what you've explained I already grasp what you're trying to achieve.

You'll want to look into using AJAX to make requests to a page that outputs data and then use that data to dynamically alter your page. My best suggestion is to use jQuery to do this, as it will make your life so much easier.

Now, while I'm suggesting things, once you've played about with the above article and got some knowledge of what to do, use JSON! It's starting to rapid become the standard for client<->server communications across various platforms.

Example time! For my example I will be using jQuery to communicate back and forth with a PHP server. So, first step is to ask the server for something. The jQuery getJSON function allows us to give it an object with parameters which will be sent as GET headers, like this...

var params = {
ID: 52
};
$.getJSON('server.php', params, function(response)
{
// Here we will use the response from the server to
// manipulate small chi-- the page, we will manipulate
// the page.
// Bare in mind this function is NOT run straight away as
// it's called, it has to wait for the response from the server
// first. Keep this in mind.
});

On the server's end we would grab the data given to us and make a reply (imagine we did some complex database query with the ID sent to get us the name and address of a user). As we're wanting JSON, the PHP script makes use of its inbuilt json_encode() function to create the following.

{"name":"P Sherman","address":"42 Wallaby Way, Sydney"}

Normally you would want to run $.parseJSON() on the response, but we used getJSON which is clever, it does it automatically for us! If we had of used get we would have needed to parse it ourselves.