How does Google hide HTML source of search results?

烂漫一生 提交于 2019-12-01 20:58:42

Google builds the DOM with the javascript you noted. It does this for a number of reasons:

  • Decrease the load on the server to generate each dynamic result set with HTML markup.
  • Google returns the results in a JSON feed (example) - pastebin. Less processing power is required to produce the JSON response than a full HTML snippet or completely new page
  • Speed. Assuming that the user has a decent internet connection, the speed of the pages rendering on the client side compared to the server side is negligible.

As suggested above, jump into firebug and have a look around :)

Google does that by generating the page using a pile of client side JavaScript. It's almost certainly a side effect, not a design goal.

Google loads additional elements via Ajax, so you won't get them if you view the source. You can use something like Firebug to check the DOM elements after you make a new query.

That link actually explains it quite clearly. The real point is, Google isn't "hiding" anything. There is an extra layer to all of this, which is called the DOM (Document Object Model). When a page is requested from a web server, the web server might respond with some basic HTML and a lot of JavaScript code. This response is then interpreted by your browser. It will load the HTML elements into the DOM, and then get started on churning through all of the JavaScript code, this JavaScript usually consists of a lot of instructions which manipulate the DOM (the in-memory representation of the page). It might load some extra data and insert new bits and pieces to display. The "browser window" if you like, renders whatever is in the DOM. Which is not necessarily the same as whatever is in the original request, because of all the instructions that have run even before the page is rendered inside your "browser window".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!