open-graph-scraper
Advanced tools
Comparing version 2.4.2 to 2.5.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48170
1246
+ Addedajv@4.11.8(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedco@4.6.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhar-schema@1.0.5(transitive)
+ Addedhar-validator@4.2.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedjschardet@1.4.2(transitive)
+ Addedjson-stable-stringify@1.1.1(transitive)
+ Addedjsonify@0.0.1(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedperformance-now@0.2.0(transitive)
+ Addedqs@6.4.1(transitive)
+ Addedrequest@2.81.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedcaseless@0.11.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcommander@2.20.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedgenerate-function@2.3.1(transitive)
- Removedgenerate-object-property@1.2.0(transitive)
- Removedhar-validator@2.0.6(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedis-my-ip-valid@1.0.1(transitive)
- Removedis-my-json-valid@2.20.6(transitive)
- Removedis-property@1.0.2(transitive)
- Removedjschardet@1.4.1(transitive)
- Removedjsonpointer@5.0.1(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedqs@6.3.3(transitive)
- Removedrequest@2.79.0(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedtunnel-agent@0.4.3(transitive)
- Removedxtend@4.0.2(transitive)
Updatedjschardet@1.4.2
Updatedrequest@2.81.0