File tree 4 files changed +1436
-911
lines changed
4 files changed +1436
-911
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @open-automaton/automaton-engine" ,
3
3
"homepage" : " https://github.com/open-automaton/automaton-engine" ,
4
- "version" : " 0.0.9 " ,
4
+ "version" : " 0.1.0 " ,
5
5
"main" : " src/automaton-engine.js" ,
6
6
"description" : " A base class for scraping engines" ,
7
7
"keywords" : [],
17
17
},
18
18
"dependencies" : {
19
19
"clone" : " ^2.1.2" ,
20
- "libxmljs" : " ^0.19.7"
20
+ "libxmljs" : " ^1.0.9" ,
21
+ "libxmljs2" : " ^0.32.0"
22
+ },
23
+ "scripts" : {
24
+ "test" : " mocha test/test.js"
21
25
},
22
26
"devDependencies" : {
23
27
"body-parser" : " ^1.19.1" ,
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ DOM.next = function(node){
54
54
return node . next ;
55
55
} ;
56
56
DOM . xpathText = function ( selector , value ) {
57
- if ( ! libs . libxmljs ) libs . libxmljs = require ( "libxmljs " ) ;
57
+ if ( ! libs . libxmljs ) libs . libxmljs = require ( "libxmljs2 " ) ;
58
58
var xmlDoc = libs . libxmljs . parseHtmlString ( value ) ;
59
59
var result = xmlDoc . find ( selector ) ;
60
60
var results = [ ] ;
Original file line number Diff line number Diff line change 1
1
const should = require ( 'chai' ) . should ( ) ;
2
- const path = require ( 'path' ) ;
3
- const Automaton = require ( '@open-automaton/automaton' ) ;
4
- const fs = require ( 'fs' ) ;
5
- const express = require ( 'express' ) ;
6
- const bodyParser = require ( 'body-parser' ) ;
2
+ const { DOM } = require ( '../src/dom-tool.js' ) ;
7
3
8
4
describe ( 'strip-mine' , function ( ) {
9
5
describe ( 'automaton' , function ( ) {
10
- it . skip ( 'generic test' , function ( done ) {
11
-
6
+ it ( 'xpath works' , function ( ) {
7
+ const result = DOM . xpathText (
8
+ '//bar/baz/text()' ,
9
+ '<foo><bar><baz>woot</baz></bar></foo>'
10
+ ) ;
11
+ result . length . should . equal ( 1 ) ;
12
+ should . exist ( result [ 0 ] ) ;
13
+ result [ 0 ] . should . equal ( 'woot' ) ;
12
14
} ) ;
13
15
} ) ;
14
16
} ) ;
You can’t perform that action at this time.
0 commit comments