uni.request({
url: 'https://192.168.1.62:3000/accounts/login/ajax/',
method: 'POST',
data: {
username:username,
userpass:userpass,
queryParams: {}
},
header:{
"user-agent":'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
},
success: res => {
console.log(res)
},
fail: () => {},
complete: () => {}
});
}
因为要做一款爬虫应用,需要从别的网站上爬取数据,可能需要添加一些特殊的header,例如origin,user-agent这些,按道理说原生Android、ios里都是没有跨域限制,也不会限制header,为什么我在手机上测试也提示不允许加这些请求头呢?
15:29:59.031 29:47.465 18854 18854 I console : [ERROR] Refused to set unsafe header "User-Agent"
3***@qq.com
你解决了修改请求头吗
2020-07-21 17:45