-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
feat(route):新增新浪黑猫投诉热点 #17492
base: master
Are you sure you want to change the base?
feat(route):新增新浪黑猫投诉热点 #17492
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||||
/* | ||||||||
* @Descripttion: description | ||||||||
* @Author: -0V | ||||||||
* @Date: 2024-11-01 10:59:51 | ||||||||
* @LastEditTime: 2024-11-07 16:11:14 | ||||||||
*/ | ||||||||
import { Route } from '@/types'; | ||||||||
|
||||||||
import logger from '@/utils/logger'; | ||||||||
import puppeteer from '@/utils/puppeteer'; | ||||||||
import { load } from 'cheerio'; | ||||||||
|
||||||||
export const route: Route = { | ||||||||
path: '/tousu', | ||||||||
name: '黑猫投诉', | ||||||||
url: 'tousu.sina.com.cn', | ||||||||
example: '/sina/tousu', | ||||||||
maintainers: ['JianLinWei1'], | ||||||||
radar: [ | ||||||||
{ | ||||||||
source: ['tousu.sina.com.cn'], | ||||||||
}, | ||||||||
], | ||||||||
handler, | ||||||||
}; | ||||||||
|
||||||||
async function handler() { | ||||||||
const browser = await puppeteer(); | ||||||||
const page = await browser.newPage(); | ||||||||
const link = 'https://tousu.sina.cn'; | ||||||||
logger.http(`Requesting ${link}`); | ||||||||
await page.goto(link, { | ||||||||
waitUntil: 'networkidle2', | ||||||||
}); | ||||||||
const response = await page.content(); | ||||||||
page.close(); | ||||||||
const $ = load(response); | ||||||||
const blackcatCons = $('div.blackcat-con').toArray(); | ||||||||
const items = blackcatCons.map((item) => { | ||||||||
const title = $(item).find('h1.blackcat-hot').text(); | ||||||||
const link = $(item).find('a.box').attr('href'); | ||||||||
const description = $(item).find('p').text() + $(item).find('ul.list').text(); | ||||||||
const author = $(item).find('span.name').text(); | ||||||||
return { | ||||||||
title, | ||||||||
link, | ||||||||
description, | ||||||||
author, | ||||||||
}; | ||||||||
}); | ||||||||
return { | ||||||||
title: `黑猫投诉-新浪旗下消费者服务平台`, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
link: `https://tousu.sina.cn`, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make use of the declared variable RSSHub/lib/routes/sina/tousu.ts Line 30 in 958709c
Suggested change
|
||||||||
description: `feedId:74988831961543680+userId:74002328552935424`, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
item: items, | ||||||||
}; | ||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary use of puppeteer. You should prioritise using APIs to obtain data instead of using puppeteer.
The API endpoint is
https://tousu.sina.cn/api/index/feed
and you can use query likeand the data is available in
response.result.data.lists