metaget - Nodejs module to fetch remote Meta Tags (including Open Graph) from URL
Words: 204 - (2 min read)
A Node.js module to fetch HTML meta tags (including Open Graph) from a remote URL
Installation
npm install metaget --save
Usage
var metaget = require("metaget");
metaget.fetch('https://wordpress.com', function (err, meta_response) {
if(err){
console.log(err);
}else{
console.log(meta_response);
}
});
Response will be a Javascript Object containing all the meta tags from the URL. All tags are output in the example above. Some tags with illegal characters can be accessed by:
meta_response["og:title"];
Options
It's possible to set any HTTP headers in the request. This can be done by specifying them as options in the call. If no options are provided the only default header is a User-Agent of "request".
This is how you would specify a "User-Agent" of a Google Bot:
var metaget = require("metaget");
metaget.fetch('https://wordpress.com',{headers:{"User-Agent": "Googlebot"}}, function (err, meta_response) {
if(err){
console.log(err);
}else{
console.log(meta_response);
}
});
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D