1 Replies - 3334 Views - Last Post: 23 November 2012 - 03:14 AM

#1 complete  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 109
  • Joined: 12-April 07

How does Yandex do its trick?

Posted 16 November 2012 - 01:33 AM

How does Yandex do its trick?

I want to programatically get the contents of a Yandex.com search result.

The proglem is that a search page url does not change when you do a search on yandex.com and advance to see more pages. It must be done somehow by javascript. Any ideas?


I am using IE. Here are the steps.

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.

Is This A Good Question/Topic? 0
  • +

Replies To: How does Yandex do its trick?

#2 Kruithne  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 99
  • View blog
  • Posts: 442
  • Joined: 28-July 09

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.

See here: http://api.jquery.com/jQuery.get/

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.

JSON - http://www.json.org/
jQuery getJSON - http://api.jquery.com/jQuery.getJSON/

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.

So, inside that function the value response.name would equal P Sherman.

I hope this is some help to you and I didn't ramble on for no reason. If you have any questions feel free to expose them below and I'm sure someone will help you if not myself!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1