How to retrieve the "head" of a html document using YQL ?

I'm curious if this is possible at all since a "select * from html" query only returns the body of the document.

2 Replies
  • Use XPath to ask for (items in) the <head> like

    select * from html where url="http://developer.yahoo.com/yql/" and xpath='/html/head/*'

    Which gives:

    <meta content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" name="generator"/>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
    <meta content="The YQL platform provides a single endpoint service that enables developers to query, filter and combine data across Yahoo! and beyond." name="description"/>
    <link href="http://l.yimg.com/a/combo?/yui/2.6.0/build/reset-fonts-grids/reset-fonts-grids.css&amp;/yui/2.6.0/build/menu/assets/skins/sam/menu.css&amp;/yui/2.6.0/build/button/assets/skins/sam/button.css&amp;/yui/2.6.0/build/container/assets/skins/sam/container.css&amp;/yui/2.6.0/build/treeview/assets/skins/sam/treeview.css&amp;/ydn/site/ydn-116217.css&amp;" rel="stylesheet" type="text/css"/>
    <link href="/iphoneicon3.png" rel="apple-touch-icon" type="image/png"/>
    <link href="http://l.yimg.com/a/i/ydn/favicon2.ico" rel="shortcut icon" type="image/x-icon"/>
    <link href="http://l.yimg.com/a/i/us/pps/yql32.png" rel="icon" type="image/png"/>
    <title>Yahoo! Query Language - YDN</title>

    Of course, the XPath query (or other parts of the main YQL query) that you use can be much more restrictive if you only want specific pieces of the <head> to be part of the result set but the above should give you a nudge in the right direction. :)
  • Thanks a lot! It works great.

    I had a feeling that the solution would have something to do with XPath but couldn't figure out how to do this. :)

Recent Posts

in YQL