Skip to content

Commit 19ab742

Browse files
Merge pull request #14 from marcomontalbano/update-dependencies
Update npm dependencies
2 parents cd53fef + 36f12ba commit 19ab742

File tree

8 files changed

+1183
-1709
lines changed

8 files changed

+1183
-1709
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_js:
66
- "11"
77
- "12"
88
- "13"
9+
- "14"
910

1011
script:
1112
- npm test

docs/app.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/demo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const path = require('path');
32
const fs = require('fs');
43
const htmlMiner = require('../lib');

examples/site.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const url = require('url');
32
const https = require('https');
43
const htmlMiner = require('../lib');

package-lock.json

Lines changed: 1094 additions & 1694 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-miner",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "A powerful miner that will scrape html pages for you. ` HTML Scraper ´",
55
"main": "index.js",
66
"repository": "https://github.com/marcomontalbano/html-miner.git",
@@ -37,21 +37,21 @@
3737
},
3838
"dependencies": {
3939
"cheerio": "^0.22.0",
40-
"lodash": "~4.17.15"
40+
"lodash": "~4.17.19"
4141
},
4242
"devDependencies": {
43-
"@babel/cli": "~7.8.4",
44-
"@babel/core": "~7.9.0",
45-
"@babel/preset-env": "~7.9.0",
43+
"@babel/cli": "~7.10.5",
44+
"@babel/core": "~7.11.0",
45+
"@babel/preset-env": "~7.11.0",
4646
"babel-eslint": "~10.1.0",
4747
"babel-preset-minify": "~0.5.1",
4848
"browserify": "~16.5.1",
4949
"chai": "^4.2.0",
5050
"eslint": "^6.8.0",
51-
"eslint-config-airbnb-base": "~14.1.0",
52-
"eslint-plugin-import": "~2.20.2",
53-
"mocha": "^7.1.1",
54-
"nyc": "~15.0.1",
51+
"eslint-config-airbnb-base": "~14.2.0",
52+
"eslint-plugin-import": "~2.22.0",
53+
"mocha": "^7.2.0",
54+
"nyc": "~15.1.0",
5555
"rest": "^2.0.0"
5656
}
5757
}

test/example.md.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const chai = require('chai');
2+
3+
const { assert } = chai;
4+
5+
const htmlMiner = require('../lib');
6+
7+
describe('htmlMiner • EXAMPLE.md', () => {
8+
it('Get text and href from a list of <a>', () => {
9+
const html = `
10+
<div>
11+
<a class="link-class" href="https://example.com/1">Link 1</a>
12+
<a class="link-class" href="https://example.com/2">Link 2</a>
13+
</div>
14+
`;
15+
16+
const actual = htmlMiner(html, {
17+
_each_: '.link-class',
18+
text: (arg) => arg.$scope.text(),
19+
href: (arg) => arg.$scope.attr('href'),
20+
});
21+
22+
assert.deepEqual(actual, [
23+
{
24+
text: 'Link 1',
25+
href: 'https://example.com/1',
26+
},
27+
{
28+
text: 'Link 2',
29+
href: 'https://example.com/2',
30+
},
31+
]);
32+
});
33+
34+
describe('Get src and alt from <img>', () => {
35+
const html = `
36+
<img src="/image-1.jpg" alt="Image 1" />
37+
<img src="/image-2.jpg" alt="Image 2" />
38+
`;
39+
40+
const doAssert = (actual) => {
41+
assert.deepEqual(actual, [
42+
{
43+
src: '/image-1.jpg',
44+
alt: 'Image 1',
45+
},
46+
{
47+
src: '/image-2.jpg',
48+
alt: 'Image 2',
49+
},
50+
]);
51+
};
52+
53+
it('Selector as function', () => {
54+
const actual = htmlMiner(html, (arg) => {
55+
const $images = Array.from(arg.$('img'));
56+
return $images.map((img) => {
57+
const $currentImage = arg.$(img);
58+
return {
59+
src: $currentImage.attr('src'),
60+
alt: $currentImage.attr('alt'),
61+
};
62+
});
63+
});
64+
65+
doAssert(actual);
66+
});
67+
68+
it('Simpler way', () => {
69+
const actual = htmlMiner(html, {
70+
_each_: 'img',
71+
src: (arg) => arg.$scope.attr('src'),
72+
alt: (arg) => arg.$scope.attr('alt'),
73+
});
74+
75+
doAssert(actual);
76+
});
77+
});
78+
});

test/test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const chai = require('chai');
32

43
const { assert } = chai;
@@ -49,7 +48,6 @@ describe('htmlMiner', () => {
4948
});
5049
});
5150

52-
5351
//
5452
describe('should returns an undefined', () => {
5553
it('given an incorrect html (e.g. \'undefined\')', () => {
@@ -454,7 +452,6 @@ describe('htmlMiner', () => {
454452
});
455453
});
456454

457-
458455
it('should work with complex combination', () => {
459456
const actual = htmlMiner(html, {
460457
title: 'h1',

0 commit comments

Comments
 (0)