Skip to content

Commit b07e0ed

Browse files
authored
Merge pull request #15 from GoBeromsu/master
feat: use direct YES24 API endpoint for book search
2 parents 6fd5a62 + 8d328df commit b07e0ed

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/searchUrl.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)