refactor: named import cheerio.load (#22477)
This commit is contained in:
parent
604b8773d5
commit
ee32cffa05
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -14,7 +14,7 @@ const handler = async (ctx) => {
|
|||
const currentUrl = `${rootUrl}${category}/`;
|
||||
const response = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
|
||||
const pattern = /item=(\[\{.*?\}\]);/;
|
||||
const newsList = JSON.parse($('script[language="javascript"]').text().match(pattern)?.[1].replaceAll("'", '"') || '[]');
|
||||
|
|
@ -29,7 +29,7 @@ const handler = async (ctx) => {
|
|||
topNewsList.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
const $ = load(detailResponse.data);
|
||||
|
||||
item.description = $('.word').html();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
||||
export const getItem = async (item) => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const reduxState = JSON.parse($('script#__REDUX_STATE__').text().replaceAll(':undefined', ':null').match('__REDUX_STATE__=(.*);')?.[1] || '{}');
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ export const getItem = async (item) => {
|
|||
};
|
||||
|
||||
const renderArticle = (asset, link: string) => {
|
||||
const $ = cheerio.load(asset.body, null, false);
|
||||
const $ = load(asset.body, null, false);
|
||||
$('x-placeholder').each((_, el) => {
|
||||
const $el = $(el);
|
||||
const id = $el.attr('id');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
|
|
@ -23,7 +23,7 @@ async function handler() {
|
|||
method: 'get',
|
||||
url,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const resultItem = $('.media')
|
||||
.toArray()
|
||||
.map((elem) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -44,7 +44,7 @@ async function handler() {
|
|||
const res = await page.evaluate(() => document.documentElement.innerHTML);
|
||||
await page.close();
|
||||
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
|
||||
const list = $('div h3 a')
|
||||
.toArray()
|
||||
|
|
@ -68,7 +68,7 @@ async function handler() {
|
|||
waitUntil: 'domcontentloaded',
|
||||
});
|
||||
const res = await page.evaluate(() => document.documentElement.innerHTML);
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
await page.close();
|
||||
|
||||
item.description = $('div.article__body').html();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -35,7 +35,7 @@ async function handler() {
|
|||
const url = `${homepage}/f/article/articleList?pageNo=1&pageSize=15&createTimeSort=DESC`;
|
||||
const response = await got(url);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const articles = $('.aw-item').toArray();
|
||||
|
||||
const items = await Promise.all(
|
||||
|
|
@ -46,7 +46,7 @@ async function handler() {
|
|||
|
||||
return cache.tryGet(link, async () => {
|
||||
const result = await got(link);
|
||||
const $ = cheerio.load(result.data);
|
||||
const $ = load(result.data);
|
||||
return {
|
||||
title,
|
||||
author: $('.user_name').text(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Context } from 'hono';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
|
|
@ -12,7 +12,7 @@ const handler = async (ctx: Context) => {
|
|||
const url = `https://www.chiphell.com/portal.php?mod=list&catid=${catId}`;
|
||||
|
||||
const response = await ofetch(url);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('dl.cl')
|
||||
.toArray()
|
||||
|
|
@ -32,7 +32,7 @@ const handler = async (ctx: Context) => {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
$('#article_content div br').parent().remove();
|
||||
let description = $('#article_content').html();
|
||||
|
|
@ -46,7 +46,7 @@ const handler = async (ctx: Context) => {
|
|||
})
|
||||
.slice(0, -1);
|
||||
const responses = await Promise.all(urls.map((url) => ofetch(url)));
|
||||
const $pages = responses.map((item) => cheerio.load(item));
|
||||
const $pages = responses.map((item) => load(item));
|
||||
const contents = $pages.map(($item) => {
|
||||
$item('#article_content div br').parent().remove();
|
||||
return $item('#article_content').html();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import type { CheerioAPI } from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Element } from 'domhandler';
|
||||
|
||||
import type { Data, DataItem, Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -13,11 +15,11 @@ const ARTICLE_TITLE_SELECTOR = ARTICLE_CONTENT_SELECTOR + ' > h1';
|
|||
// 获取消息列表 / get article list
|
||||
const fetchPageContent = async (url: string) => {
|
||||
const response = await ofetch(url);
|
||||
return cheerio.load(response);
|
||||
return load(response);
|
||||
};
|
||||
|
||||
// 提取正文内容 / extract article content
|
||||
const extractArticleInfo = ($article: cheerio.Root, pageURL: string) => {
|
||||
const extractArticleInfo = ($article: CheerioAPI, pageURL: string) => {
|
||||
const contentElement = $article(ARTICLE_CONTENT_SELECTOR);
|
||||
const title = $article(ARTICLE_TITLE_SELECTOR).text();
|
||||
$article(ARTICLE_TITLE_SELECTOR).remove(); // 移除标题,避免重复 / remove title to avoid duplication
|
||||
|
|
@ -31,7 +33,7 @@ const parseDateString = (dateString: string) => {
|
|||
};
|
||||
|
||||
// 创建消息 / create article
|
||||
const createDataItem = (item: cheerio.Element, $: cheerio.Root): Promise<DataItem> => {
|
||||
const createDataItem = (item: Element, $: CheerioAPI): Promise<DataItem> => {
|
||||
const $item = $(item);
|
||||
const link = $item.find('a').attr('href');
|
||||
const dateString = $item.find('a').text().split(' ').at(-1);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -53,7 +53,7 @@ const getPost = (item) =>
|
|||
throw new Error(post.message);
|
||||
}
|
||||
|
||||
const $ = cheerio.load(post.data.body, null, false);
|
||||
const $ = load(post.data.body, null, false);
|
||||
|
||||
$('img').each((_, img) => {
|
||||
img = $(img);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import sanitizeHtml from 'sanitize-html';
|
||||
import xxhash from 'xxhash-wasm';
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ async function handler() {
|
|||
link,
|
||||
async () => {
|
||||
const response = await ofetch(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
return JSON.parse($('script#__NEXT_DATA__').text());
|
||||
},
|
||||
config.cache.routeExpire,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
|
|
@ -112,7 +112,7 @@ export const route: Route = {
|
|||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(article.content.story, null, false);
|
||||
const $ = load(article.content.story, null, false);
|
||||
$('*').each((_, ele) => {
|
||||
if (junkPattern.test(ele.name)) {
|
||||
$(ele).remove();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { destr } from 'destr';
|
||||
import { raw } from 'hono/html';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
|
@ -25,7 +25,7 @@ const handler = async (ctx) => {
|
|||
|
||||
const response = await ofetch(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const list = [
|
||||
...$('div[class^="max-w-[100%]"] > div > div:nth-child(2) > a')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
|
|
@ -30,7 +30,7 @@ export const route: Route = {
|
|||
async function handler(ctx) {
|
||||
const { app } = ctx.req.param();
|
||||
const { data: response } = await got(`https://f-droid.org/en/packages/${app}/`);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const appName = $('.package-title').find('h3').text().trim();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { raw } from 'hono/html';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ function getBuildId() {
|
|||
'famitsu:buildId',
|
||||
async () => {
|
||||
const data = await ofetch(baseUrl);
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
const nextData = JSON.parse($('#__NEXT_DATA__').text());
|
||||
return nextData.buildId;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Context } from 'hono';
|
||||
|
||||
import type { Data, Route } from '@/types';
|
||||
|
|
@ -71,7 +71,7 @@ async function handler(ctx: Context): Promise<Data> {
|
|||
const link = `https://fanqienovel.com/page/${bookId}`;
|
||||
|
||||
const response = await ofetch(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const initialState = JSON.parse(
|
||||
$('script:contains("window.__INITIAL_STATE__")')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -9,11 +9,11 @@ const jjmhw = 'http://www.jjmhw.cc';
|
|||
const getLatestAddress = () =>
|
||||
cache.tryGet('freexcomic:getLatestAddress', async () => {
|
||||
const portalResponse = await ofetch('https://www.freexcomic.com');
|
||||
const $portal = cheerio.load(portalResponse);
|
||||
const $portal = load(portalResponse);
|
||||
const portalUrl = new URL($portal('.alert-btn').attr('href')).href.replace('http:', 'https:');
|
||||
|
||||
const addressList = await ofetch(portalUrl);
|
||||
const $address = cheerio.load(addressList);
|
||||
const $address = load(addressList);
|
||||
|
||||
return $address('p.ta-c.mb10 a')
|
||||
.toArray()
|
||||
|
|
@ -27,7 +27,7 @@ const handler = async (ctx) => {
|
|||
const link = `${addresses[0]}book/${id}`;
|
||||
|
||||
const response = await ofetch(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('#detail-list-select > li > a')
|
||||
.toArray()
|
||||
|
|
@ -46,7 +46,7 @@ const handler = async (ctx) => {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const comicpage = $('.comicpage');
|
||||
comicpage.find('img').each((_, ele) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
|
|
@ -19,7 +19,7 @@ export const parseList = (result) =>
|
|||
export const parseItem = (item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const { data: res } = await got(`https://apis.guokr.com/minisite/article/${item.id}.json`);
|
||||
const $ = cheerio.load(res.result.content);
|
||||
const $ = load(res.result.content);
|
||||
|
||||
$('#meta_content').remove();
|
||||
$('div').each((_, elem) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
import type { DataItem, Route } from '@/types';
|
||||
|
|
@ -137,7 +137,7 @@ async function handler(ctx) {
|
|||
|
||||
const response = await ofetch(`${baseUrl}/${category}`);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('.main-listing-container div.listing-title > a')
|
||||
.toArray()
|
||||
|
|
@ -185,7 +185,7 @@ async function handler(ctx) {
|
|||
}
|
||||
|
||||
const response = await ofetch(item.link!);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
item.category = $('.contentTags-container > .hotkey-container-wrapper > .hotkey-container > a')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
|
@ -9,13 +9,13 @@ const handler = async () => {
|
|||
const pageUrl = 'https://www.weather.gov.hk/en/wxinfo/currwx/current.htm';
|
||||
|
||||
const data = await ofetch(url);
|
||||
const $ = cheerio.load(data, {
|
||||
const $ = load(data, {
|
||||
xmlMode: true,
|
||||
});
|
||||
|
||||
const description = $('item').first().find('description');
|
||||
|
||||
const $$ = cheerio.load(description.text());
|
||||
const $$ = load(description.text());
|
||||
|
||||
const items = $$('table tr')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import { config } from '@/config';
|
||||
import type { Route } from '@/types';
|
||||
|
|
@ -80,7 +80,7 @@ async function handler(ctx) {
|
|||
'hypergryph:arknights:news',
|
||||
async () => {
|
||||
const response = await ofetch('https://ak.hypergryph.com/news');
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const renderData = JSON.parse(
|
||||
$('script:contains("initialData")')
|
||||
.first()
|
||||
|
|
@ -99,7 +99,7 @@ async function handler(ctx) {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const description = $('div > div > div > div > div > div > div:nth-child(4)');
|
||||
item.description = description.length ? description.html() : item.description;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import { config } from '@/config';
|
||||
import type { Route } from '@/types';
|
||||
|
|
@ -73,7 +73,7 @@ async function handler(ctx) {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
// The detail page's article HTML appears in one of two shapes
|
||||
// within the Next.js RSC stream (self.__next_f.push chunks):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Context } from 'hono';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ async function handler(ctx: Context) {
|
|||
const link = `${baseUrl}/chart/${chart}/`;
|
||||
|
||||
const response = await ofetch(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const nextData = JSON.parse($('script#__NEXT_DATA__').text());
|
||||
const chartTitles = nextData.props.pageProps.pageData.chartTitles as ChartTitleSearchConnection;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import crypto from 'node:crypto';
|
||||
|
||||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import cache from '@/utils/cache';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
|
@ -44,7 +44,7 @@ export const generateUuid = () => {
|
|||
|
||||
export const getArticle = async (link) => {
|
||||
let response = await ofetch(link);
|
||||
let $ = cheerio.load(response);
|
||||
let $ = load(response);
|
||||
if ($('script').text().includes('_wafchallengeid')) {
|
||||
const cs = $('script:contains("_wafchallengeid")')
|
||||
.text()
|
||||
|
|
@ -57,7 +57,7 @@ export const getArticle = async (link) => {
|
|||
},
|
||||
});
|
||||
|
||||
$ = cheerio.load(response);
|
||||
$ = load(response);
|
||||
}
|
||||
|
||||
return $('.article-viewer').html();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Context } from 'hono';
|
||||
import { raw } from 'hono/html';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
|
@ -103,7 +103,7 @@ const handler = async (ctx: Context) => {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const content = $('.bodytext-data')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { DataItem, Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -70,7 +70,7 @@ Language codes for the \`${Parameter.Language}\` parameter:
|
|||
// Article content may not always be available, e.g: https://wutheringwaves.kurogames.com/zh-tw/main/news/detail/2596
|
||||
const articleContent = articleDetails.articleContent ?? '';
|
||||
|
||||
const $ = cheerio.load(articleContent);
|
||||
const $ = load(articleContent);
|
||||
|
||||
item.description = $.html() ?? article.articleDesc ?? '';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Context } from 'hono';
|
||||
import markdownit from 'markdown-it';
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ async function handler(ctx: Context) {
|
|||
|
||||
const response = await ofetch(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('.card-body > a')
|
||||
.slice(0, ctx.req.query('limit') ? Number(ctx.req.query('limit')!) : 30)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -59,7 +59,7 @@ async function handler(ctx) {
|
|||
posts.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
item.description = $('div#rendered-preview').html();
|
||||
|
||||
return item;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -16,7 +16,7 @@ interface Tag {
|
|||
const getTagId = (tid: string) =>
|
||||
cache.tryGet(`matters:tags:${tid}`, async () => {
|
||||
const response = await ofetch(`${baseUrl}/tags/${tid}`);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const nextData = JSON.parse($('script#__NEXT_DATA__').text());
|
||||
|
||||
const node = Object.entries(nextData.props.apolloState.data.ROOT_QUERY)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { raw } from 'hono/html';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ async function handler(ctx) {
|
|||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const topVideo = $('#topvideo').length
|
||||
? $('#topvideo iframe')
|
||||
.toArray()
|
||||
|
|
@ -155,7 +155,7 @@ async function handler(ctx) {
|
|||
?.replaceAll(String.raw`\"`, '"')
|
||||
: '';
|
||||
if (lowerContent) {
|
||||
const $ = cheerio.load(lowerContent, null, false);
|
||||
const $ = load(lowerContent, null, false);
|
||||
fancybox = [
|
||||
...fancybox,
|
||||
...$('a.fancybox')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// import ofetch from '@/utils/ofetch';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
|
|
@ -57,7 +57,7 @@ async function handler() {
|
|||
// },
|
||||
// });
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const items = $('.grid .group')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -53,7 +53,7 @@ async function handler(ctx) {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
item.description =
|
||||
$('#icon').html() +
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { raw } from 'hono/html';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ async function handler(ctx) {
|
|||
const creatorData = (await cache.tryGet(`patreon:creator:${creator}`, async () => {
|
||||
const response = await ofetch(link);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const ogUrl = $('meta[property="og:url"]').attr('content');
|
||||
if (ogUrl?.startsWith(`${baseUrl}/cw/`)) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
|
@ -7,7 +7,7 @@ const handler = async () => {
|
|||
const url = 'https://www.psnine.com/psngame';
|
||||
const response = await ofetch(url);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const out = $('table tr')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
|
@ -8,7 +8,7 @@ const handler = async () => {
|
|||
const url = 'https://www.psnine.com/';
|
||||
const response = await ofetch(url);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const out = $('.list li')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -13,7 +13,7 @@ const handler = async (ctx) => {
|
|||
const currentUrl = `${rootUrl}/node/${id}?ob=${order}`;
|
||||
const response = await ofetch(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
$('.psnnode, .node').remove();
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ const handler = async (ctx) => {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await ofetch(item.link);
|
||||
const $ = cheerio.load(detailResponse);
|
||||
const $ = load(detailResponse);
|
||||
|
||||
item.author = $('a[itemprop="author"]').eq(0).text();
|
||||
item.description = $('div[itemprop="articleBody"]').html();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
|
@ -7,7 +7,7 @@ const handler = async () => {
|
|||
const url = 'https://www.psnine.com/dd';
|
||||
const response = await ofetch(url);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const out = $('.dd_ul li')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
|
@ -8,7 +8,7 @@ const handler = async () => {
|
|||
const url = 'https://www.psnine.com/trade';
|
||||
const response = await ofetch(url);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const out = $('.list li')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -98,7 +98,7 @@ async function handler(ctx) {
|
|||
const currentUrl = config[category].url;
|
||||
const response = await ofetch(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('.list-style1 ul li a, .text h2 a, .no-pic ul li a')
|
||||
.slice(0, limit)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -27,7 +27,7 @@ async function handler(ctx) {
|
|||
const link = `${baseUrl}/${magazine}/mulu.htm`;
|
||||
const yearResponse = await ofetch(link);
|
||||
|
||||
const $ = cheerio.load(yearResponse);
|
||||
const $ = load(yearResponse);
|
||||
|
||||
const yearList = $('.booktitle a')
|
||||
.toArray()
|
||||
|
|
@ -40,7 +40,7 @@ async function handler(ctx) {
|
|||
});
|
||||
|
||||
const issueResponse = await ofetch(yearList[0].link);
|
||||
const $$ = cheerio.load(issueResponse);
|
||||
const $$ = load(issueResponse);
|
||||
|
||||
const list = $$('.highlight a')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
|
@ -7,7 +7,7 @@ export const baseUrl = 'http://www.qstheory.cn';
|
|||
|
||||
export const getItem = async (item) => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
$('.fs-text, .fs-pinglun, .hidden-xs').remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import type { Cheerio } from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Element } from 'domhandler';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -23,8 +25,8 @@ export const route: Route = {
|
|||
async function handler() {
|
||||
const baseUrl = 'https://info-maimai.sega.jp/';
|
||||
|
||||
const parseContent = (htmlString: string, image: cheerio.Cheerio<cheerio.Element>) => {
|
||||
const $ = cheerio.load(htmlString);
|
||||
const parseContent = (htmlString: string, image: Cheerio<Element>) => {
|
||||
const $ = load(htmlString);
|
||||
const content = $('.maiMd');
|
||||
content.prepend(image);
|
||||
content.find('.hrLine').replaceWith('<hr/>');
|
||||
|
|
@ -32,7 +34,7 @@ async function handler() {
|
|||
};
|
||||
|
||||
const response = await got(baseUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = load(response.data);
|
||||
const list = $('.maiPager-content .newsBox');
|
||||
|
||||
const item = await Promise.all(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -45,7 +45,7 @@ async function handler() {
|
|||
try {
|
||||
description = await cache.tryGet(guid, async () => {
|
||||
const result = await got.get(`https://production-web.sekai.colorfulpalette.org/html/${path}.html`);
|
||||
const $ = cheerio.load(result.data);
|
||||
const $ = load(result.data);
|
||||
return $.html();
|
||||
});
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import type { CheerioAPI } from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -34,7 +35,7 @@ export const route: Route = {
|
|||
async function handler() {
|
||||
const response = await ofetch('https://m.sohu.com/limit');
|
||||
// 从HTML中提取JSON数据
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const jsonScript = $('script:contains("WapHomeRenderData")').text();
|
||||
const jsonMatch = jsonScript?.match(/window\.WapHomeRenderData\s*=\s*(\{.*\})/s);
|
||||
if (!jsonMatch?.[1]) {
|
||||
|
|
@ -52,14 +53,14 @@ async function handler() {
|
|||
cache.tryGet(item.link, async () => {
|
||||
try {
|
||||
const detailResp = await ofetch(item.link);
|
||||
const $d = cheerio.load(detailResp);
|
||||
const $d = load(detailResp);
|
||||
|
||||
let description = '';
|
||||
let pubDate = '';
|
||||
if (item.link.includes('/xtopic/')) {
|
||||
const fullArticleUrl = $d('.tpl-top-text-item-content').prop('href')?.split('?', 1)[0]?.replace('www.sohu.com/', 'm.sohu.com/');
|
||||
const response = await ofetch(`https:${fullArticleUrl}`);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
description = getDescription($);
|
||||
pubDate = extractPubDate($);
|
||||
}
|
||||
|
|
@ -108,7 +109,7 @@ function extractPlateBlockNewsLists(jsonData: any) {
|
|||
return result;
|
||||
}
|
||||
|
||||
function extractPubDate($: cheerio.CheerioAPI): string {
|
||||
function extractPubDate($: CheerioAPI): string {
|
||||
const timeElements = ['.time', '#videoPublicTime'];
|
||||
let date;
|
||||
for (const selector of timeElements) {
|
||||
|
|
@ -133,7 +134,7 @@ function extractPubDate($: cheerio.CheerioAPI): string {
|
|||
}
|
||||
}
|
||||
|
||||
function getDescription($: cheerio.CheerioAPI): string | null {
|
||||
function getDescription($: CheerioAPI): string | null {
|
||||
const content = $('#articleContent');
|
||||
if (content.length) {
|
||||
return content.first().html()?.trim();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import CryptoJS from 'crypto-js';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ function createAuthToken() {
|
|||
function fetchArticle(item) {
|
||||
return cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
$('.original-title, .lookall-box').remove();
|
||||
item.author ||= $('span[data-role="original-link"] a').text();
|
||||
|
|
@ -118,7 +118,7 @@ async function handler(ctx) {
|
|||
?.getSetCookie()
|
||||
.find((e) => e.startsWith('SUV'))
|
||||
?.split(';', 1)[0];
|
||||
const $ = cheerio.load(pageResponse._data);
|
||||
const $ = load(pageResponse._data);
|
||||
|
||||
const CBDRenderConst = JSON.parse(
|
||||
$('script:contains("CBDRenderConst")')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
||||
import { config } from '@/config';
|
||||
|
|
@ -38,7 +38,7 @@ const handler = async () => {
|
|||
});
|
||||
|
||||
const response = await page.content();
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const items = $('.video-item')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -67,7 +67,7 @@ async function handler(ctx) {
|
|||
isValidType && url.searchParams.set('type', type);
|
||||
|
||||
const { data: res } = await got(url);
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
const list = $('#ajaxtable > tbody:nth-child(2) .tr3')
|
||||
.not('.tr2.tac')
|
||||
.toArray()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import type { CheerioAPI } from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -7,7 +8,7 @@ import { parseDate } from '@/utils/parse-date';
|
|||
|
||||
import { baseUrl, parseContent } from './utils';
|
||||
|
||||
function parseItems(tid: string, $: cheerio.CheerioAPI) {
|
||||
function parseItems(tid: string, $: CheerioAPI) {
|
||||
return $('.tr1:nth-child(1)')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
|
|
@ -60,14 +61,14 @@ async function handler(ctx) {
|
|||
const tid = ctx.req.param('tid') as string;
|
||||
const { data: response } = await got(`${baseUrl}/read.php?tid=${tid}`);
|
||||
// 跟踪重定向
|
||||
let $ = cheerio.load(response);
|
||||
let $ = load(response);
|
||||
const redirect = $('a:last-child').attr('href');
|
||||
if (!redirect) {
|
||||
throw new Error('Cannot get the redirect link');
|
||||
}
|
||||
|
||||
const { data: redirectedResponse, url: link } = await got(new URL(redirect, baseUrl).href);
|
||||
$ = cheerio.load(redirectedResponse);
|
||||
$ = load(redirectedResponse);
|
||||
|
||||
const firstPage = parseItems(tid, $);
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ async function handler(ctx) {
|
|||
pageUrls.map((url) =>
|
||||
cache.tryGet(url, async () => {
|
||||
const { data: res } = await got(url);
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
|
||||
return parseItems(tid, $);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
export const baseUrl = 'https://www.t66y.com';
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ const killRedircdn = (originUrl) => {
|
|||
};
|
||||
|
||||
export const parseContent = (htmlString) => {
|
||||
const $ = cheerio.load(htmlString);
|
||||
const $ = load(htmlString);
|
||||
|
||||
const content = $('div.tpc_content').eq(0);
|
||||
content.find('.t_like').remove();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import { ViewType } from '@/types';
|
||||
|
|
@ -35,7 +35,7 @@ async function handler() {
|
|||
const link = 'https://telegram.org/blog';
|
||||
|
||||
const res = await ofetch(link);
|
||||
const $$ = cheerio.load(res);
|
||||
const $$ = load(res);
|
||||
|
||||
const items = await Promise.all(
|
||||
$$('.dev_blog_card_link_wrap')
|
||||
|
|
@ -45,7 +45,7 @@ async function handler() {
|
|||
const link = 'https://telegram.org' + $.attr('href');
|
||||
return cache.tryGet(link, async () => {
|
||||
const result = await ofetch(link);
|
||||
const $ = cheerio.load(result);
|
||||
const $ = load(result);
|
||||
return {
|
||||
title: $('#dev_page_title').text(),
|
||||
link,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -110,7 +110,7 @@ async function handler(ctx) {
|
|||
|
||||
const mobileBuildId = (await cache.tryGet('thepaper:m:buildId', async () => {
|
||||
const response = await ofetch('https://m.thepaper.cn');
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const nextData = JSON.parse($('script#__NEXT_DATA__').text());
|
||||
return nextData.buildId;
|
||||
})) as string;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -33,7 +33,7 @@ async function handler(ctx) {
|
|||
Page: 1,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
|
||||
const list = $('.news_list ul li')
|
||||
.toArray()
|
||||
|
|
@ -51,7 +51,7 @@ async function handler(ctx) {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const { data: res } = await got(item.link);
|
||||
const $ = cheerio.load(res);
|
||||
const $ = load(res);
|
||||
|
||||
if (item.link.startsWith('https://tonglinv.pixnet.net/')) {
|
||||
item.description = $('.article-content-inner').html();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -29,7 +29,7 @@ async function handler() {
|
|||
page: 1,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('.grid__column')
|
||||
.toArray()
|
||||
|
|
@ -47,7 +47,7 @@ async function handler() {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const content = $('.newsentry');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
|
|
@ -27,7 +27,7 @@ async function handler(ctx) {
|
|||
const link = `${baseUrl}/tag/${tag}/`;
|
||||
|
||||
const response = await ofetch(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const preloadedState = JSON.parse(
|
||||
$('script:contains("window.__PRELOADED_STATE__")')
|
||||
.text()
|
||||
|
|
@ -47,7 +47,7 @@ async function handler(ctx) {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const preloadedState = JSON.parse(
|
||||
$('script:contains("window.__PRELOADED_STATE__")')
|
||||
.text()
|
||||
|
|
@ -57,7 +57,7 @@ async function handler(ctx) {
|
|||
const headerLeadAsset = $('div[data-testid*="ContentHeaderLeadAsset"]');
|
||||
headerLeadAsset.find('button').remove();
|
||||
// false postive: 'some' does not exist on type 'Cheerio<Element>'
|
||||
// eslint-disable-next-line unicorn/prefer-array-some
|
||||
// oxlint-disable-next-line unicorn/prefer-array-some
|
||||
if (headerLeadAsset.find('video')) {
|
||||
headerLeadAsset.find('video').attr('src', $('link[rel="preload"][as="video"]').attr('href'));
|
||||
headerLeadAsset.find('video').attr('controls', '');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import type { Context } from 'hono';
|
||||
import { raw } from 'hono/html';
|
||||
import { renderToString } from 'hono/jsx/dom/server';
|
||||
|
|
@ -32,7 +32,7 @@ async function handler(ctx: Context) {
|
|||
const link = `https://yenpress.com/series/${series}`;
|
||||
|
||||
const response = await ofetch(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const list = $('.show-more-container .inline_block')
|
||||
.toArray()
|
||||
|
|
@ -48,7 +48,7 @@ async function handler(ctx: Context) {
|
|||
list.map((item) =>
|
||||
cache.tryGet(item.link!, async () => {
|
||||
const response = await ofetch(item.link!);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
item.category = $('.detail-labels.mobile-only')
|
||||
.eq(0)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import dayjs from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration.js';
|
||||
import { google } from 'googleapis';
|
||||
|
|
@ -65,7 +65,7 @@ export const getDataByUsername = async ({ username, embed, filterShorts, isJsonF
|
|||
userHandleData = await cache.tryGet(`youtube:handle:${username}`, async () => {
|
||||
const link = `https://www.youtube.com/${username}`;
|
||||
const response = await ofetch(link);
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
const ytInitialData = JSON.parse(
|
||||
$('script')
|
||||
.text()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import pMap from 'p-map';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
|
|
@ -29,7 +29,7 @@ async function handler(ctx) {
|
|||
|
||||
const { cookie, data } = await getSafeLineCookieWithData(link);
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
const feedTitle = $('head title').text();
|
||||
const list = parseList($);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import pMap from 'p-map';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
|
|
@ -25,7 +25,7 @@ async function handler() {
|
|||
|
||||
const { cookie, data } = await getSafeLineCookieWithData(link);
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const $ = load(data);
|
||||
const list = parseList($);
|
||||
|
||||
const items = await pMap(list, (item) => cache.tryGet(item.link!, () => fetchItem(item, cookie)), { concurrency: 2 });
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import type { CheerioAPI } from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
import { config } from '@/config';
|
||||
|
|
@ -6,8 +7,7 @@ import type { DataItem } from '@/types';
|
|||
import cache from '@/utils/cache';
|
||||
import logger from '@/utils/logger';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
|
||||
const hints = ['globalThis', 'headless', 'languages', 'permHook', 'vendor', 'webDriverValue', 'webdriver'];
|
||||
export const baseUrl = 'https://www.myzaker.com';
|
||||
|
|
@ -52,7 +52,13 @@ export const getSafeLineCookieWithData = async (link): Promise<{ cookie: string;
|
|||
const cacheAge = 3600;
|
||||
const cacheIn = await cache.get(cacheKey, false);
|
||||
if (cacheIn) {
|
||||
return JSON.parse(cacheIn);
|
||||
const cookie = JSON.parse(cacheIn);
|
||||
const data = await ofetch<string>(link, {
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
return { cookie, data };
|
||||
}
|
||||
const apiBaseUrl = 'https://challenge.rivers.chaitin.cn/captcha/api';
|
||||
|
||||
|
|
@ -146,7 +152,7 @@ export const getSafeLineCookieWithData = async (link): Promise<{ cookie: string;
|
|||
};
|
||||
};
|
||||
|
||||
export const parseList = ($: cheerio.CheerioAPI) => {
|
||||
export const parseList = ($: CheerioAPI) => {
|
||||
const winPageData = JSON.parse(
|
||||
$('script:contains("window.WinPageData")')
|
||||
.text()
|
||||
|
|
@ -158,7 +164,7 @@ export const parseList = ($: cheerio.CheerioAPI) => {
|
|||
description: item.desc,
|
||||
link: 'https:' + item.url,
|
||||
author: item.author_name,
|
||||
pubDate: timezone(parseDate(item.date, 'MM月DD日'), 8),
|
||||
pubDate: parseRelativeDate(item.date, 'MM月DD日'),
|
||||
category: item.tag.map((t) => t.tag),
|
||||
image: item.thumbnail_mpic,
|
||||
})) as DataItem[];
|
||||
|
|
@ -171,7 +177,7 @@ export const fetchItem = async (item: DataItem, cookie: string) => {
|
|||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const $ = load(response);
|
||||
|
||||
const content = $('div.article_content div');
|
||||
content.find('img').each((_, img) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import type { Route } from '@/types';
|
||||
import { ViewType } from '@/types';
|
||||
|
|
@ -23,7 +23,7 @@ export const route: Route = {
|
|||
async function handler() {
|
||||
const urlData = await ofetch('https://www.zhizhuan100.com.cn/analysis');
|
||||
|
||||
const $ = cheerio.load(urlData);
|
||||
const $ = load(urlData);
|
||||
|
||||
const bodyJsUrl: string | undefined = $('script[src*="Body.js"]').attr('src');
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ async function handler() {
|
|||
}
|
||||
|
||||
const htmlContent = JSON.parse(`"${htmlMatch[1]}"`);
|
||||
const $content = cheerio.load(htmlContent);
|
||||
const $content = load(htmlContent);
|
||||
|
||||
const listItems = $content('.w-list-item');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue