File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ class Crawler {
7171 try {
7272 response = await axios . post ( this . __grahpqlURL , PostQuery ( this . username , url_slug ) ) ;
7373 } catch ( e ) {
74- console . error ( `⚠️ 벨로그에서 글을 가져오는데 실패했습니다. \n error = ${ e } ` ) ;
74+ console . error ( `⚠️ 벨로그에서 글을 가져오는데 실패했습니다. \n error = ${ e } url = ${ url_slug } ` ) ;
7575 process . exit ( 1 ) ;
7676 }
7777
@@ -92,12 +92,14 @@ class Crawler {
9292 }
9393
9494 async getImage ( body ) {
95- const regex = / ! \[ [ ^ \] ] * \] \( (?< filename > .* ?) (? = \" | \) ) (?< optionalpart > \" . * \" ) ? \) / g;
96-
95+ const regex = / ! \[ [ ^ \] ] * \] \( ( .* ?. p n g | . j p e g | . j p g | . w e b p | . s v g | . g i f | . t i f f ) \s * ( " (?: . * [ ^ " ] ) " ) ? \s * \) | ! \[ [ ^ \] ] * \] \( ( . * ? ) \s * ( " (?: . * [ ^ " ] ) " ) ? \s * \) / g;
96+
9797 body = body . replace ( regex , ( _ , url ) => {
98+ if ( ! url ) return ;
99+
98100 const filename = url . replace ( / \/ \s * $ / , '' ) . split ( '/' ) . slice ( - 2 ) . join ( '-' ) . trim ( ) ;
99101 const path = join ( 'backup' , 'images' , decodeURI ( filename ) ) ;
100-
102+
101103 axios ( {
102104 method : 'get' ,
103105 url : encodeURI ( decodeURI ( url ) ) ,
@@ -111,6 +113,7 @@ class Crawler {
111113
112114 return body ;
113115 }
116+
114117} ;
115118
116119module . exports = Crawler ;
You can’t perform that action at this time.
0 commit comments