diff --git a/.inscode b/.inscode index e1777316cc8a34b6c53f0ae12504b6c66fbdb272..b6e34e079f7d11879531645ab00c59646175b4d9 100644 --- a/.inscode +++ b/.inscode @@ -1,5 +1,8 @@ -run = "npm i && npm run dev" +run = "npm run dev" language = "node" +is_html = false +is_resident = true +is_gui = false [env] PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" diff --git a/index.js b/index.js index 2d7e6834fb6366b3120c7a37cc5f637bc4a33928..9d37756d0d737eb2467c95ed612641036b0fc4f6 100644 --- a/index.js +++ b/index.js @@ -1 +1,60 @@ -console.log("欢迎来到 InsCode"); \ No newline at end of file +const express = require('express'); +const puppeteer = require('puppeteer-extra'); +const StealthPlugin = require('puppeteer-extra-plugin-stealth'); + +// 添加stealth插件 +puppeteer.use(StealthPlugin());peteer.use(StealthPlugin()); + +const app = express(); +const PORT = process.env.PORT || 3000; + +// 基本路由 +app.get('/', (req, res) => { + res.send(` +
这是一个使用Express和Puppeteer的示例项目
+Example.com的标题是: ${title}
+ 返回首页 + `); + } catch (error) { + res.status(500).send(`Error: ${error.message}`); + } +}); + +// 启动服务器 +app.listen(PORT, () => { + console.log(`Server running at http://localhost:${PORT}`); + console.log(`Puppeteer version: ${puppeteer.version}`); +}); \ No newline at end of file diff --git a/package.json b/package.json index 72caa1750a1c44c18460a496d258fbd3c51c673a..2c1767f2c43202f8ff4d5736fc7626fa8f784de2 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,23 @@ { "name": "nodejs", "version": "1.0.0", - "description": "", + "description": "Node.js project with Express and Puppeteer", "main": "index.js", "scripts": { "dev": "node index.js", + "start": "node index.js", "test": "echo \"Error: no test specified\" && exit 1" }, - "keywords": [], - "author": "", + "keywords": ["node", "express", "puppeteer"], + "author": "Your Name", "license": "ISC", "dependencies": { - "@types/node": "^18.0.6", - "node-fetch": "^3.2.6" + "@types/node": "^20.11.19", + "node-fetch": "^3.3.2", + "express": "^4.18.2", + "puppeteer": "^22.8.1", + "puppeteer-extra": "^3.3.6", + "puppeteer-extra-plugin-stealth": "^2.11.1" } } \ No newline at end of file