Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

open-graph-scraper

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

open-graph-scraper - npm Package Compare versions

Comparing version 2.4.2 to 2.5.0

0

.eslintrc.json

@@ -0,0 +0,0 @@ {

25

app.js

@@ -314,17 +314,18 @@ var request = require('request'),

var hasCallback = typeof callback === 'function';
var done = function (error, info, source) {
var done = function (error, info, response) {
if (error) {
if (hasCallback) {
callback(error, info);
callback(error, info, response);
}
return reject(error, info);
return reject(error, response);
}
if (hasCallback) {
callback(error, info, source);
callback(error, info, response);
}
return resolve(info, source);
return resolve(info, response);
};
that.getInfo(options, done);
})
.catch(function () {
.catch(function (error) {
if (error) console.log('Open Graph Error: ', error);
// there was a error passed back

@@ -356,3 +357,3 @@ });

}
that.getOG(options, function (err, results, source) {
that.getOG(options, function (err, results, response) {
if (results) {

@@ -390,3 +391,3 @@ returnResult = {

}
callback(error, returnResult, source);
callback(error, returnResult, response);
});

@@ -456,7 +457,7 @@ } else {

if (err) {
callback(err, null);
callback(err, null, response);
} else if (response && response.statusCode && (response.statusCode.toString().substring(0, 1) === '4' || response.statusCode.toString().substring(0, 1) === '5')) {
callback(new Error('Error from server'), null);
callback(new Error('Error from server'), null, response);
} else if (!(response && response.headers && response.headers['content-type'] && response.headers['content-type'].indexOf('text/html') !== -1)) {
callback('Must scrape an HTML page', null);
callback('Must scrape an HTML page', null, response);
} else {

@@ -623,5 +624,5 @@ if (options.encoding === null) {

// console.log('ogObject',ogObject);
callback(null, ogObject, body);
callback(null, ogObject, response);
}
});
};
{
"name": "open-graph-scraper",
"description": "Node.js scraper service for Open Graph info",
"version": "2.4.2",
"version": "2.5.0",
"license": "MIT",
"main": "app.js",
"scripts": {
"test": "mocha tests/"
},
"engines": {

@@ -19,5 +22,5 @@ "node": "6.x"

"iconv-lite": "0.4.15",
"jschardet": "1.4.1",
"jschardet": "1.4.2",
"lodash": "4.17.4",
"request": "2.79.0"
"request": "2.81.0"
},

@@ -27,5 +30,5 @@ "devDependencies": {

"mocha": "3.2.0",
"eslint": "3.12.2",
"eslint-plugin-promise": "3.4.0",
"eslint-plugin-standard": "2.0.1"
"eslint": "3.18.0",
"eslint-plugin-promise": "3.5.0",
"eslint-plugin-standard": "2.1.1"
},

@@ -32,0 +35,0 @@ "repository": {

@@ -42,10 +42,10 @@ openGraphScraper

If you would like the source of the page you scraped you can grab it as the third param:
If you would like the response of the page you scraped you can grab it as the third param:
```
var ogs = require('open-graph-scraper');
var options = {'url': 'http://ogp.me/', 'timeout': 4000};
ogs(options, function (err, results, source) {
ogs(options, function (err, results, response) {
console.log('err:', err); // This is returns true or false. True if there was a error. The error it self is inside the results object.
console.log('results:', results);
console.log('source:', source); // Source of the page
console.log('response:', response); // The whole Response Object
});

@@ -52,0 +52,0 @@ ```

@@ -146,3 +146,3 @@ var app = require('../app'),

it('Valid Call - ogp.me should return open graph data', function (done) {
app(options1, function (err, result, source) {
app(options1, function (err, result, response) {
console.log('err:', err);

@@ -160,3 +160,3 @@ console.log('result:', result);

expect(result.data.ogImage.type).to.be('image/png');
expect(source.length > 0).to.be(true);
expect(response).to.be.an('object');
done();

@@ -341,4 +341,4 @@ });

expect(result.success).to.be(true);
expect(result.data.ogTitle).to.be('Twitter. It\'s what\'s happening.');
expect(result.data.ogDescription).to.be('From breaking news and entertainment to sports and politics, get the full story with all the live commentary.');
expect(result.data.ogTitle.length > 0).to.be(true);
expect(result.data.ogDescription.length > 0).to.be(true);
done();

@@ -453,13 +453,2 @@ });

expect(result.data.ogImage.type).to.be('image/png');
expect(result.data.twitterSite).to.be('github');
expect(result.data.twitterSiteId).to.be('13334762');
expect(result.data.twitterCreator).to.be('github');
expect(result.data.twitterCreatorId).to.be('13334762');
expect(result.data.twitterCard).to.be('summary_large_image');
expect(result.data.twitterTitle).to.be('GitHub');
expect(result.data.twitterDescription).to.be.a('string');
expect(result.data.twitterImage.url).to.be('https://assets-cdn.github.com/images/modules/open_graph/github-logo.png');
expect(result.data.twitterImage.width).to.be('1200');
expect(result.data.twitterImage.height).to.be('1200');
expect(result.data.twitterImage.alt).to.be(null);
done();

@@ -466,0 +455,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc