Skip to content

Commit

Permalink
fix: continue fixing mangaoh items' price and date logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaharico committed Feb 20, 2024
1 parent 3f1fe0c commit e7accfd
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions packages/get-bonus/src/mangaoh/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,34 @@ export class Mangaoh extends Provider {
const descs = doc
.querySelector('.thickbox:last-of-type')
?.nextElementSibling?.textContent?.split?.('+');
const dateSelector = doc.querySelector('.spec-table > tbody:nth-child(1) > tr > th:contains("発売日")');
const date = dateSelector?.nextElementSibling?.textContent?.trim();
const priceSelector = doc.querySelector('.spec-table > tbody:nth-child(1) > tr > th:contains("価格")');
const price = resolvePrice(
priceSelector?.nextElementSibling?.textContent?.trim()
);
const tbody = doc.querySelector('.spec-table > tbody:nth-child(1)');
const rows = tbody?.querySelectorAll('tr');
let date;
let price;
rows?.forEach(row => {
const thElements = row.querySelectorAll('th');
thElements.forEach(th => {
if (th.textContent?.trim() === '発売日') {
// 找到包含“発売日”的<th>,选择其后的<td>
const tdElement = th.nextElementSibling;
if (tdElement && tdElement.tagName.toLowerCase() === 'td') {
date = tdElement.textContent?.trim();
}
}
});
});
rows?.forEach(row => {
const thElements = row.querySelectorAll('th');
thElements.forEach(th => {
if (th.textContent?.trim() === '価格') {
// 找到包含“価格”的<th>,选择其后的<td>
const tdElement = th.nextElementSibling;
if (tdElement && tdElement.tagName.toLowerCase() === 'td') {
price = resolvePrice(tdElement.textContent?.trim());
}
}
});
});
const items = [...imgs].map(
(img, i) =>
<DetailItem>{
Expand Down

0 comments on commit e7accfd

Please sign in to comment.