开发者

javascript code to analyze the url and generate the summary like google buzz?

I am using google buzz, one of it's functionalities is when I paste a URL into the input box, it will begin to fetch the url and generate a small summary box of that page.

It basically consists of the tit开发者_开发知识库le of the page, the images inside the page and possible the first paragraph of the page.

I want to know how google did that? Is there any library that I can use in my website?


There is no ready-built library to do that, but what Google is doing conceptually is the following:

  • Listen to the text-input box for a URL
  • When URL entered, make HTTP GET request for the URL
  • That code is retrieved and parsed, server-side, and certain elements are catalogued, in this case the page title, the first or largest sized image on the page, and possibly the h1 or h2 elements
  • Those elements are returned to AJAX listener in the form of a JSON object and are decoded by the AJAX callback function to display in the page

You can find several tutorials about how to do this if you explore some of the cross-browser AJAX libraries, such as MooTools, jQuery, or Dojo. Google and Yahoo also have UI libraries that assist with this.

You will need both a frontend and a backend architecture to accomodate.

Best of luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜