Skip to content

Commit

Permalink
fix(route): dcfever (#17179)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Oct 17, 2024
1 parent 3d34710 commit f455df8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 3 additions & 5 deletions lib/routes/dcfever/trading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ async function handler(ctx) {
const response = await ofetch(link.href);
const $ = load(response);

const list = $('.item_list li a')
const list = $('.item_grid_wrap div a')
.toArray()
.filter((item) => $(item).attr('href') !== '/documents/advertising.php')
.map((item) => {
item = $(item);
item.find('.optional').remove();
return {
title: item.find('.trade_title').text(),
title: item.find('.lazyloadx').attr('alt'),
link: new URL(item.attr('href'), link.href).href,
author: item.find('.trade_info').text(),
author: item.find('.trade_info div span').eq(1).text(),
};
});

Expand Down
17 changes: 13 additions & 4 deletions lib/routes/dcfever/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ const parseTradeItem = (item) =>
const response = await ofetch(item.link);
const $ = load(response);

$('.selector_text').remove();
$('.selector_image_div').each((_, div) => {
const photoSelector = $('#trading_item_section .description')
.contents()
.filter((_, e) => e.type === 'comment')
.toArray()
.map((e) => e.data)
.join('');

const $photo = load(photoSelector, null, false);

$photo('.selector_text').remove();
$photo('.selector_image_div').each((_, div) => {
delete div.attribs.onclick;
});
$('.desktop_photo_selector img').each((_, img) => {
$photo('.desktop_photo_selector img').each((_, img) => {
if (img.attribs.src.endsWith('_sqt.jpg')) {
img.attribs.src = img.attribs.src.replace('_sqt.jpg', '.jpg');
}
Expand All @@ -76,7 +85,7 @@ const parseTradeItem = (item) =>
item.description = art(path.join(__dirname, 'templates/trading.art'), {
info: $('.info_col'),
description: $('.description_text').html(),
photo: $('.desktop_photo_selector').html(),
photo: $photo('.desktop_photo_selector').html(),
});

return item;
Expand Down

0 comments on commit f455df8

Please sign in to comment.