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

google-search-parser2

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-search-parser2 - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

2

package.json
{
"name": "google-search-parser2",
"version": "0.0.8",
"version": "0.0.9",
"description": "Parse image and Knowledge Graph data from Google Search results",

@@ -5,0 +5,0 @@ "main": "parser.js",

@@ -88,3 +88,4 @@ var htmlparser = require("htmlparser2");

url: metaObject.ou,
caption: metaObject.pt
caption: metaObject.pt,
dimensions: metaObject.ow + "x" + metaObject.oh
});

@@ -137,12 +138,12 @@ count++;

onopentag: function (name, attribs) {
if (name === "div" && attribs.class === "kno-ecr-pt kno-fb-ctx") {
if (name === "div" && attribs.class && attribs.class.includes("kno-ecr-pt") && attribs.class.includes("kno-fb-ctx")) {
isInsideTitleTag = true;
}
if (name === "div" && attribs.class === "_mr kno-fb-ctx") {
if (name === "div" && attribs.class && attribs.class.includes("kno-fb-ctx")) {
isInsideContextItemTag = true;
}
if (isInsideContextItemTag && name === "span" && attribs.class === "_xdb") {
if (isInsideContextItemTag && name === "span" && attribs.class && !attribs.class.includes("kno-fv")) {
isInsideKeyTag = true;
}
if (isInsideContextItemTag && name === "span" && attribs.class === "_Xbe kno-fv") {
if (isInsideContextItemTag && name === "span" && attribs.class && attribs.class.includes("kno-fv")) {
isInsideValueTag = true;

@@ -149,0 +150,0 @@ }

@@ -41,4 +41,4 @@ # google-search-parser2

parser.parseImageUrls(searchTerm, function (urls) {
console.log(urls); // [ { url: "https://upload.wikimedia.org/wikipedia/en/f/f4/Supermarioworld.jpg", caption: "foo" }, { url: "http ...
console.log(urls); // [ { url: "https://upload.wikimedia.org/wikipedia/en/f/f4/Supermarioworld.jpg", caption: "foo", dimensions: "320x240" }, { url: "http ...
});
```

@@ -1,2 +0,2 @@

/*global describe, it, expect, jasmine */
/*global describe, it, xit, expect, jasmine */

@@ -24,3 +24,3 @@ describe("Parser", function () {

it("returns expected result", function (done) {
it("results have a title", function (done) {
// arrange

@@ -33,10 +33,13 @@ var parser = new Parser(request);

// assert
var expected = {
title: "Donkey Kong Country 2: Diddy's Kong Quest",
year: 1995
};
for (var i = 0; i < results.length; i++) {
var singleResult = results[i];
expect(results).toContain(expected);
expect(singleResult.title).toEqual(jasmine.any(String));
}
done();
});
xit("results have a year", function () {
// TODO: add missing test for cases when (optionally) results have a year
});
});

@@ -63,3 +66,3 @@ });

it("has expected title", function (done) {
it("has a title", function (done) {
// arrange

@@ -72,3 +75,3 @@ var parser = new Parser(request);

// assert
expect(results.title).toEqual(searchTerm);
expect(results.title).toEqual(jasmine.any(String));
done();

@@ -78,3 +81,3 @@ });

it("has expected properties", function (done) {
it("has properties", function (done) {
// arrange

@@ -87,6 +90,4 @@ var parser = new Parser(request);

// assert
expect(results.genre).toEqual("Platform game");
expect(results.developers).toContain("Nintendo");
expect(results.designers).toContain("Shigeru Miyamoto");
expect(results.platforms).toContain("Super Nintendo Entertainment System");
expect(Object.keys(results).length).toBeGreaterThan(1);
done();

@@ -112,3 +113,3 @@ });

it("results are urls", function (done) {
it("results have a url, caption and dimensions", function (done) {
// arrange

@@ -127,2 +128,4 @@ var parser = new Parser(request);

expect(singleResult.caption).toEqual(jasmine.any(String));
expect(singleResult.dimensions).toEqual(jasmine.any(String));
expect(singleResult.dimensions).toContain("x");
}

@@ -129,0 +132,0 @@ done();

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