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

tanto

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tanto - npm Package Compare versions

Comparing version 0.2.1 to 1.0.0

LICENSE

7

History.md

@@ -0,1 +1,8 @@

2/22/2016 - 1.0.0
==================
* Updated cheerio and request.
* Updated tests and dev dependencies.
* Bumped version to 1.0.0.
* Added license
7/11/2014 - 0.2.1

@@ -2,0 +9,0 @@ ==================

58

lib/tanto.js

@@ -1,4 +0,4 @@

// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.10.0
var Tanto, cheerio, request,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

@@ -10,8 +10,8 @@ request = require('request');

Tanto = (function() {
function Tanto(options, cb) {
var _base;
this.options = options;
this.cb = cb;
this.process = __bind(this.process, this);
(_base = this.options).timeout || (_base.timeout = 30000);
function Tanto(options1, cb1) {
var base1;
this.options = options1;
this.cb = cb1;
this.process = bind(this.process, this);
(base1 = this.options).timeout || (base1.timeout = 30000);
this.initSchema();

@@ -22,10 +22,10 @@ this.scrape();

Tanto.prototype.initSchema = function() {
var key, value, _base, _ref, _results;
var base1, key, ref, results, value;
this.schema = this.options.schema;
_ref = this.schema;
_results = [];
for (key in _ref) {
value = _ref[key];
ref = this.schema;
results = [];
for (key in ref) {
value = ref[key];
if (typeof value === "string") {
_results.push(this.schema[key] = {
results.push(this.schema[key] = {
selector: value,

@@ -35,6 +35,6 @@ type: "text"

} else {
_results.push((_base = this.schema[key]).type || (_base.type = "text"));
results.push((base1 = this.schema[key]).type || (base1.type = "text"));
}
}
return _results;
return results;
};

@@ -63,11 +63,11 @@

Tanto.prototype.readValues = function() {
var error, key, val, value, _ref, _results;
_ref = this.schema;
_results = [];
for (key in _ref) {
val = _ref[key];
var error, error1, key, ref, results, val, value;
ref = this.schema;
results = [];
for (key in ref) {
val = ref[key];
try {
value = this.data.$(val.selector);
} catch (_error) {
error = _error;
} catch (error1) {
error = error1;
this.addSchemaError(key, error);

@@ -77,8 +77,8 @@ continue;

if (value.length !== 0) {
_results.push(this.setKey(key, this.getValue(value, val)));
results.push(this.setKey(key, this.getValue(value, val)));
} else {
_results.push(this.addSchemaError(key, new Error("Value not found")));
results.push(this.addSchemaError(key, new Error("Value not found")));
}
}
return _results;
return results;
};

@@ -114,7 +114,7 @@

Tanto.prototype.setKey = function(key, val) {
var base, last, level, levels, _i, _len;
var base, i, last, len, level, levels;
base = this.data.values;
levels = key.split('.');
for (_i = 0, _len = levels.length; _i < _len; _i++) {
level = levels[_i];
for (i = 0, len = levels.length; i < len; i++) {
level = levels[i];
last = base;

@@ -121,0 +121,0 @@ base = base[level] = base[level] || {};

{
"name": "tanto",
"version": "0.2.1",
"version": "1.0.0",
"author": "Charles Moncrief",

@@ -11,8 +11,8 @@ "description": "Lightweight web scraping library",

"dependencies": {
"cheerio": "^0.17.0",
"request": "^2.37.0"
"cheerio": "^0.20.0",
"request": "^2.69.0"
},
"devDependencies": {
"coffee-script": "~1.6.3",
"mocha": "~1.12.0"
"coffee-script": "^1.10.0",
"mocha": "^2.4.5"
},

@@ -19,0 +19,0 @@ "scripts": {

@@ -21,3 +21,3 @@ # Tantō

of the response and the `$` object, which allows extracting data out of the response with all of the jQuery syntax available in the [cheerio module](https://npmjs.org/package/cheerio)
var tanto = require('tanto');

@@ -42,3 +42,3 @@

tanto(options, function(err, data) {
console.log(data.$('title').text());
console.log(data.$('title').text());
});

@@ -128,3 +128,3 @@

Transformation functions take `data` and `context` as parameters and return
the new value. Use the `context` parameter to alter or create other keys in the returned values.
the new value. Use the `context` parameter to alter or create other keys in the returned values.

@@ -159,3 +159,3 @@ The following is an example of a transform function that sets the scraped name

(The MIT License)
(The ISC License)

@@ -181,2 +181,2 @@ Copyright (c) 2013 Charles Moncrief <<cmoncrief@gmail.com>>

TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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