@@ -15,8 +15,6 @@ exports.parentScraper = (uri, page) => {
1515
1616 $ ( 'article' ) . each (
1717 function ( ) {
18- // let id = $(this).attr("id");
19- // let title = $(this).find('.post-title').text();
2018 let coverPage = $ ( this ) . find ( 'img' ) . attr ( 'src' ) ;
2119 let valid = $ ( this ) . find ( '.post-info' ) . children ( ) . remove ( ) . end ( ) . text ( ) ;
2220 let href = $ ( this ) . find ( 'a' ) . attr ( 'href' ) ;
@@ -35,6 +33,8 @@ exports.parentScraper = (uri, page) => {
3533 const description = $ ( '.post-contents' ) . find ( 'p' ) . first ( ) . children ( ) . remove ( ) . end ( ) . text ( ) . trim ( ) ;
3634 const infoArr = $ ( '.post-contents > p:nth-child(7)' ) . text ( ) . split ( "|" ) ;
3735 const infoStr = infoArr . splice ( 1 , 3 ) . join ( ) . toString ( ) ;
36+ const pageNumber = $ ( 'ul.page-numbers > li:nth-child(5) > a:nth-child(1)' ) . text ( )
37+ console . log ( pageNumber )
3838
3939 $ ( '.aio-pulse' ) . each ( function ( ) {
4040 const downloadLinks = $ ( this ) . children ( 'a' ) . attr ( 'href' ) ;
@@ -43,14 +43,16 @@ exports.parentScraper = (uri, page) => {
4343 downloadLinksObj [ downloadTitle ] = downloadLinks ;
4444 downloadLinksArr . push ( downloadLinksObj ) ;
4545 } ) ;
46- let info
46+ let info ;
47+ // remove out all the empty info strings
4748 if ( infoStr . length !== 0 ) {
4849 info = infoScraper ( infoStr ) ;
4950 }
50- const completeObj = {
51- title, description, coverPage, info, downloadLinks : downloadLinksArr
51+ //store all scraped data into an objects
52+ const comic = {
53+ pageNumber , title, description, coverPage, info, downloadLinks : downloadLinksArr
5254 } ;
53- resolve ( completeObj ) ;
55+ resolve ( comic ) ;
5456 } ) . catch (
5557 err => {
5658 if ( err ) { reject ( err ) ; }
@@ -62,13 +64,12 @@ exports.parentScraper = (uri, page) => {
6264 }
6365 ) ;
6466 resolve ( comics ) ;
67+ return Promise . all ( comics ) ;
6568 } ) . catch ( err => {
6669 if ( err ) { reject ( err ) ; }
6770 } ) ;
6871 } ) . then ( function ( comics ) {
69- return Promise . all ( comics ) . then ( values => {
70- return values ;
71- } ) ;
72+ return Promise . all ( comics ) ;
7273 } ) . catch ( err => {
7374 if ( err ) {
7475 console . log ( err ) ;
0 commit comments