Search code examples
proxyyqlhead

No head section when requesting page via YQL API


I'm trying to get the full page via yahoo YQL API, in order to access metadata fields defined in the target page head section (specifically open graph metadata).

My example URL:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http://www.google.com%22&format=xml

But it does not contain any metadata parameters...is there another way to call this Yahoo API to include the head section or perhaps a similar service that does include the head section?


Solution

  • You cannot use YQL to parse google.com directly, use the Community Tables

    Here's an example to get the meta tags of http://php.net/explode via YQL.

    SELECT * FROM html WHERE url = 'http://php.net/explode' AND xpath='descendant-or-self::meta'
    

    Partial Query Output:

        <results>
            <meta charset="utf-8"/>
            <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
        </results>