Created
May 17, 2014 07:13
-
-
Save hekike/d8dd9446a621ca06b886 to your computer and use it in GitHub Desktop.
Get og: metas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var http = require('http'); | |
var select = require('html-select'); | |
var tokenize = require('html-tokenize'); | |
var url = 'http://www.bbc.com/news/health-27422547'; | |
http.get(url, function (response) { | |
response | |
.pipe(tokenize()) | |
.pipe(select('meta', function (e) { | |
var ogExists = e.attributes && e.attributes.property && | |
e.attributes.property.indexOf('og:') > -1; | |
if (ogExists === true) { | |
process.stdout.write(JSON.stringify({ | |
type: e.attributes.property, | |
content: e.attributes.content | |
})); | |
process.stdout.write('\n'); | |
} | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment