修改爬虫

This commit is contained in:
编码猿
2024-11-22 12:31:44 +08:00
parent 07c46ac300
commit 8fdd65b9bb
11 changed files with 2551 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
import express from "express";
// import app from "./utils/app.js"
import { Crawl } from '../utils/crawl.js'
import Config from '../config/config.js'
const router = express.Router();
const crawlApp = new Crawl()
// http://192.168.31.101:3000/api/v1/search/hot
router.get('/hot', async (req, res) => {
const { browser, page } = await crawlApp.page(Config.baseUrl);
// await page.waitForSelector('.search-input')
res.json({
code: 200,
data: await page.$$eval('.search-keywords', el => el.map(x => { return { title: x } }))
})
})
export default router