Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

아이템 파싱 개선 #235

Merged
merged 11 commits into from
Dec 11, 2022
26 changes: 14 additions & 12 deletions src/lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,25 @@ const parsingForWconcept = async (url) => {
if (html.status == 200) {
const $ = cheerio.load(html.data);
$('meta').each((_, el) => {
const egTag = $(el).attr('property')?.split(/^eg:/)[1];
if (egTag) {
const egValue = $(el).attr('content');
switch (egTag) {
case 'itemName':
itemName = egValue;
break;
case 'itemImage':
itemImg = 'https:';
itemImg += egValue;
const ogTag = $(el).attr('property')?.split(/^og:/)[1];
if (ogTag) {
const ogValue = $(el).attr('content');
switch (ogTag) {
case 'description':
itemName = ogValue;
break;
case 'originalPrice':
itemPrice = egValue;
case 'image':
itemImg = ogValue;
break;
}
}
});
if (!itemPrice) {
// TODO 개선 필요
itemPrice = $(
'#frmproduct > div.price_wrap > dl > dd.normal > em',
).text();
}
}
});
itemPrice = itemPrice ? getPriceWithoutString(itemPrice) : undefined;
Expand Down