Browse Source

add user agents

master
filesite 1 year ago
parent
commit
352741ace5
  1. 14
      config.mjs
  2. 2
      test/scrap_test.mjs

14
config.mjs

@ -2,14 +2,20 @@ export default {
//请求参数 //请求参数
heroBotOptions: { heroBotOptions: {
timeoutMs: 10000, timeoutMs: 10000,
referrer: 'https://wechat.com', 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' 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参数 //网页tab参数
heroTabOptions: { 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',
} }
}; };

2
test/scrap_test.mjs

@ -25,7 +25,7 @@ import configs from '../config.mjs';
//西瓜测试 //西瓜测试
const url = 'https://www.ixigua.com/7092326495246516749'; const url = 'https://www.ixigua.com/7092326495246516749';
configs.heroBotOptions.referrer = url; 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); console.log('Hero配置', configs);
const xigua = new Xigua(heroCloudServer); const xigua = new Xigua(heroCloudServer);

Loading…
Cancel
Save