From 352741ace5dc9885e20cd2b591fb176db0d244d2 Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 11 Sep 2023 11:07:32 +0800 Subject: [PATCH] add user agents --- config.mjs | 14 ++++++++++---- test/scrap_test.mjs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config.mjs b/config.mjs index 80d5ee7..a759672 100644 --- a/config.mjs +++ b/config.mjs @@ -2,14 +2,20 @@ export default { //请求参数 heroBotOptions: { - timeoutMs: 10000, - referrer: 'https://wechat.com', - userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1' + timeoutMs: 10000, + referrer: 'https://wechat.com', + userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1' }, //网页tab参数 heroTabOptions: { - timeoutMs: 5000 + timeoutMs: 5000 + }, + + //常用浏览器user-agent + userAgents: { + iphone_chrome: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', + mac_chrome: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36', } }; diff --git a/test/scrap_test.mjs b/test/scrap_test.mjs index b617751..ac8d5d9 100644 --- a/test/scrap_test.mjs +++ b/test/scrap_test.mjs @@ -25,7 +25,7 @@ import configs from '../config.mjs'; //西瓜测试 const url = 'https://www.ixigua.com/7092326495246516749'; configs.heroBotOptions.referrer = url; - configs.heroBotOptions.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'; + configs.heroBotOptions.userAgent = configs.userAgents.mac_chrome; console.log('Hero配置', configs); const xigua = new Xigua(heroCloudServer);