src/index.js
function(body) {
    var $     = cheerio.load(body),
        page  = {};

    // Meta signals
    page.title = $('title').text() || null;
    page.description = $('meta[name=description]').attr('content') || null;
    page.author = $('meta[name=author]').attr('content') || null;
    page.keywords = $('meta[name=keywords]').attr('content') || null;

    // Heading signals
    var h1s = 0;
    $('h1').each(function() {
      h1s++;
    });
    page.heading1 = $('body h1:first-child').text().trim().replace('\n', '');
    page.totalHeadings = h1s;

    // Accessibility signals
    var totalImgs       = 0,
        accessibleImgs  = 0;
    $('img').each(function(index) {
      totalImgs++;
      if ($(this).attr('alt') || $(this).attr('title')) {
        accessibleImgs++;
      }
    });
    page.imgAccessibility = (accessibleImgs / totalImgs) * 100;
    return page;
  }
function(body) {
    var $     = cheerio.load(body),
        page  = {};

    // Meta signals
    page.title = $('title').text() || null;
    page.description = $('meta[name=description]').attr('content') || null;
    page.author = $('meta[name=author]').attr('content') || null;
    page.keywords = $('meta[name=keywords]').attr('content') || null;

    // Heading signals
    var h1s = 0;
    $('h1').each(function() {
      h1s++;
    });
    page.heading1 = $('body h1:first-child').text().trim().replace('\n', '');
    page.totalHeadings = h1s;

    // Accessibility signals
    var totalImgs       = 0,
        accessibleImgs  = 0;
    $('img').each(function(index) {
      totalImgs++;
      if ($(this).attr('alt') || $(this).attr('title')) {
        accessibleImgs++;
      }
    });
    page.imgAccessibility = (accessibleImgs / totalImgs) * 100;
    return page;
  }
function ( body ) { var $ = cheerio . load ( body ) , page = { } ; // Meta signals page . title = $ ( 'title' ) . text ( ) || null ; page . description = $ ( 'meta[name=description]' ) . attr ( 'content' ) || null ; page . author = $ ( 'meta[name=author]' ) . attr ( 'content' ) || null ; page . keywords = $ ( 'meta[name=keywords]' ) . attr ( 'content' ) || null ; // Heading signals var h1s = 0 ; $ ( 'h1' ) . each ( function ( ) { h1s ++ ; } ) ; page . heading1 = $ ( 'body h1:first-child' ) . text ( ) . trim ( ) . replace ( '\n' , '' ) ; page . totalHeadings = h1s ; // Accessibility signals var totalImgs = 0 , accessibleImgs = 0 ; $ ( 'img' ) . each ( function ( index ) { totalImgs ++ ; if ( $ ( this ) . attr ( 'alt' ) || $ ( this ) . attr ( 'title' ) ) { accessibleImgs ++ ; } } ) ; page . imgAccessibility = ( accessibleImgs / totalImgs ) * 100 ; return page ; }
Parse meta data from an HTTP response body

`body` [String] - The HTML of a web page to parse

Returns an object containing data related to the SEO
signals of the page that was parsed. Pass the result to
another function to determine an "SEO score".
Parse meta data from an HTTP response body