File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,19 +11,13 @@ const searchBookUrl = async (bookName: string): Promise<searchUrlOutput> => {
1111 try {
1212 const response = await requestUrl ( {
1313 url :
14- "http://www.yes24.com/Product/Search?domain=BOOK& query=" +
14+ "http://www.yes24.com/Product/searchapi/bulletsearch/goods? query=" +
1515 bookName ,
1616 } ) ;
17-
18- const parser = new DOMParser ( ) ;
19- const html = parser . parseFromString ( response . text , "text/html" ) ;
20-
21- const bookUrl = html
22- . querySelector (
23- "#yesSchList > li:nth-child(1) > div > div.item_info > div.info_row.info_name > a.gd_name"
24- )
25- . getAttribute ( "href" ) ;
26-
17+ const data = JSON . parse ( response . text ) ;
18+ const lstSearchKeywordResult = data ?. lstSearchKeywordResult ;
19+ const bookInfo = lstSearchKeywordResult [ 0 ] . GOODDS_INDEXES . GOODS_NO ;
20+ const bookUrl = `/Product/Goods/${ bookInfo } ` ;
2721 return { ok : true , url : bookUrl } ;
2822 } catch ( err ) {
2923 console . log ( err ) ;
You can’t perform that action at this time.
0 commit comments