Skip to content

Commit

Permalink
feat: 环境变量可以配置阅读网站
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Apr 29, 2024
1 parent 423adab commit fc1e52b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#支持多账户,使用逗号分隔每个账户,密码中有特殊字符可能会导致识别失败
USERNAMES=hahaha2,hahaha1,ha1,ha2,DrKBoogieWoogie,lsp,lsb #888存在问题
PASSWORDS=BfdSGt}F4!5pLHt,BfdSGt}F4!5pLHt,iTs9Wx4+3Eavkhk,W$RhQUVn5E?BBBq,]"w%2Qd%M8Z6-SS,HU5B6Ee]kRB%Qj',uYE)46Ej8phu$#u
PASSWORDS=BfdSGt}F4!5pLHt,BfdSGt}F4!5pLHt,iTs9Wx4+3Eavkhk,W$RhQUVn5E?BBBq,]"w%2Qd%M8Z6-SS,HU5B6Ee]kRB%Qj',uYE)46Ej8phu$#u
WEBSITE=https://linux.do # https://meta.discourse.org
5 changes: 3 additions & 2 deletions pteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require("dotenv").config();
// 从环境变量解析用户名和密码
const usernames = process.env.USERNAMES.split(",");
const passwords = process.env.PASSWORDS.split(",");
const loginUrl = process.env.WEBSITE;
// 每个浏览器实例之间的延迟时间(毫秒)
const delayBetweenInstances = 10000;
//随机等待时间
Expand Down Expand Up @@ -39,7 +40,7 @@ function delayClick(time) {
async function launchBrowserForUser(username, password) {
try {
const browser = await puppeteer.launch({
headless: true,
headless: false,
args: ["--no-sandbox", "--disable-setuid-sandbox"], //linux需要
defaultViewport: {
width: 1280,
Expand Down Expand Up @@ -92,7 +93,7 @@ async function launchBrowserForUser(username, password) {
// });

//登录操作
await page.goto("https://linux.do");
await page.goto(loginUrl);
console.log("登录操作");
// 使用XPath查询找到包含"登录"或"login"文本的按钮
await page.evaluate(() => {
Expand Down

0 comments on commit fc1e52b

Please sign in to comment.