html图片/视频/文件(即二进制流)防爬
正常url/blob二进制流转化为blob://http格式
转化代码示例:
<img :src="imgPic" style="height:100px;weight:100px"/>
const getImg =async() => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const imgUrl = require("@/assets/img/head1.jpeg")
const response = await fetch(imgUrl)
//取出blob二进制
const blob = await response.blob()
//赋值给需要展示的地方
state.imgPic = URL.createObjectURL(blob)
}
请求后端接口数据防爬
Request请求头headers里面添加x-haier-date、x-haier-tags参数(或者其他防爬参数)
服务端response请求头headers全部返回前端请求头里添加的参数
robots协议君子约定(软规范)
1)在public文件夹下建一个robots.txt文件,将不允许访问的目录配置在Disallow下
User-agent: *
Disallow: /
2)在index.html文件的head里面添加
<meta name="robots" content="noindex, nofollow">
3) 在服务器端设置响应头,告诉搜索引擎不要索引该页面
X-Robots-Tag: noindex, nofollow
"X-Robots-Tag"是一个响应头,"noindex"表示该页面不应该被索引,"nofollow"表示不应该跟进页面上的链接。
注:Robots协议只防君子爬虫