File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1
1
var urlparser = require ( "url-parser" ) ;
2
+ var request = require ( "request" ) ;
3
+ var jsdom = require ( "jsdom" ) ;
2
4
3
5
module . exports . test = function test ( url ) {
4
6
parsedurl = urlparser . parse ( url ) ;
@@ -18,8 +20,23 @@ module.exports.test = function test(url) {
18
20
return false ;
19
21
} ;
20
22
21
- // TODO: this should be split into multiple methods
22
23
module . exports . download = function download ( url , options , callback ) {
23
- // TODO: this needs to be implemented
24
- throw new Error ( "not implemented" ) ;
24
+ request . get ( url , function requestcallback ( error , response , body ) {
25
+ var metadata = null ;
26
+
27
+ if ( ! error && response . statusCode == 200 ) {
28
+ var window = jsdom . jsdom ( body ) . createWindow ( ) ;
29
+ var title = window . document . getElementsByTagName ( "title" ) [ 0 ] . innerHTML ;
30
+
31
+ metadata = {
32
+ "html" : {
33
+ "title" : title ,
34
+ } ,
35
+ } ;
36
+ }
37
+
38
+ callback ( error , metadata ) ;
39
+ } ) ;
40
+
41
+ return undefined ;
25
42
} ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " papermonk-downloader-plosone" ,
3
3
"description" : " plosone.org scraper" ,
4
- "version" : " 0.0.1 " ,
4
+ "version" : " 0.0.2 " ,
5
5
"readmeFilename" : " README.md" ,
6
6
"homepage" : " https://github.com/kanzure/papermonk-downloader-plosone" ,
7
7
"author" : {
43
43
},
44
44
"dependencies" : {
45
45
"url-parser" : " >0" ,
46
+ "request" : " ~2.26.0" ,
47
+ "jsdom" : " ~0.8.0" ,
46
48
"tape" : " >0"
47
49
},
48
50
"optionalDependencies" : {
You can’t perform that action at this time.
0 commit comments