Created
October 19, 2011 10:13
-
-
Save naoya/1297897 to your computer and use it in GitHub Desktop.
Scraping OpenGraph w/ node + jsdom + jQuery
This file contains 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
jsdom = require 'jsdom' | |
jsdom.env | |
html: 'http://b.hatena.ne.jp/articles/201110/6114' | |
scripts: [ 'http://code.jquery.com/jquery-1.6.4.min.js' ] | |
done: (errors, window) -> | |
$ = window.$ | |
og = {} | |
$('meta[property^="og:"]').each () -> | |
og[ $(@).attr('property').match(/og:(.+)$/)[1] ] = $(@).attr 'content' | |
console.log og.title | |
console.log og.url | |
console.log og.image | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you not get the attributes with querySelector? its not working for me.