修改爬虫
This commit is contained in:
20
newBackApi/router/search.js
Normal file
20
newBackApi/router/search.js
Normal 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
|
||||
Reference in New Issue
Block a user