BOSS直聘的反爬机制怎么办啊
我看微博的返回页面和这个返回页面都差不多好像,怎么改进一下呐,刚学。求教大佬我的代码:import requests
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/536.36 SLBrowser/8.0.0.4152 SLBChan/11'
} #请求头里面的内容不能有空格
url = 'https://www.zhipin.com/c100010000/d_204/?query=Java&page=1&ka=page-1'
res = requests.get(url,headers=headers)
print(res.text)
print(len(res.text))
结果:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<title>èˉ·ç¨å</title>
<style>
html,
body {
margin: 0;
width: 100%;
height: 100%;
}
@keyframes bossLoading {
0% {
transform: translate3d(0, 0, 0);
}
50% {
transform: translate3d(0, -10px, 0);
}
}
.data-tips {
text-align: center;
height: 100%;
position: relative;
background: #fff;
top: 50%;
margin-top: -37px;
}
.data-tips .boss-loading {
width: 100%;
}
.data-tips .boss-loading p {
margin-top: 10px;
color: #9fa3b0;
}
.boss-loading .component-b,
.boss-loading .component-s1,
.boss-loading .component-o,
.boss-loading .component-s2 {
display: inline-block;
width: 40px;
height: 42px;
line-height: 42px;
font-family: Helvetica Neue,Helvetica,Arial,Hiragino Sans GB,Hiragino Sans GB W3,Microsoft YaHei UI,Microsoft YaHei,WenQuanYi Micro Hei,sans-serif;
font-weight: bolder;
font-size: 40px;
color: #eceef2;
vertical-align: top;
-webkit-animation-fill-mode: both;
-webkit-animation: bossLoading 0.6s infinite linear alternate;
-moz-animation: bossLoading 0.6s infinite linear alternate;
animation: bossLoading 0.6s infinite linear alternate;
}
.boss-loading .component-o {
-webkit-animation-delay: 0.1s;
-moz-animation-delay: 0.1s;
animation-delay: 0.1s;
}
.boss-loading .component-s1 {
-webkit-animation-delay: 0.2s;
-moz-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.boss-loading .component-s2 {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
animation-delay: 0.3s;
}
</style>
</head>
<body>
<div class="data-tips">
<div class="tip-inner">
<div class="boss-loading">
<span class="component-b">B</span><span class="component-o">O</span><span class="component-s1">S</span><span class="component-s2">S</span>
<p class="gray">æ-£å¨å è½½ä¸-...</p>
</div>
</div>
</div>
<script>
var securityPageName="securityCheck";(function(){var image=new Image;var url=window.location.href;var lenSrcReferer=url.split("srcReferer").length-1;image.src="https://t.zhipin.com/f.gif?pk="+securityPageName+"&len="+lenSrcReferer+"&r="+document.referrer})();(function(){var pageInterNum=0;var pageStartTime=(new Date).getTime();var UA=window.navigator.userAgent;var isIE;if(UA.indexOf("MSIE ")>-1){isIE=true}function init(frame){var COOKIE_DOMAIN=function(){var hostName=location.hostname;if(hostName==="localhost"||/^(\d+\.){3}\d+$/.test(hostName)){return hostName}return"."+hostName.split(".").slice(-2).join(".")}();var seriesLoadScript=function(scriptUrl,callback){var url=scriptUrl;var script=document.createElement("script");script.setAttribute("type","text/javascript");script.setAttribute("charset","UTF-8");script.onload=script.onreadystatechange=function(){if(!isIE||this.readyState=="loaded"||this.readyState=="complete"){callback()}};script.setAttribute("src",scriptUrl);if(frame.tagName!="IFRAME"){frame.appendChild(script)}else if(frame.contentDocument){if(frame.contentDocument.body){frame.contentDocument.body.appendChild(script)}else{frame.contentDocument.documentElement.appendChild(script)}}else if(frame.document){if(frame.document.body){frame.document.body.appendChild(script)}else{frame.document.documentElement.appendChild(script)}}};var getQueryString=function(name){var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");var r=window.location.search.substr(1).match(reg);if(r!=null)return unescape(r);return null};var Cookie={get:function(name){var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");if(arr=document.cookie.match(reg)){return unescape(arr)}else{return null}},set:function(name,value,time,domain,path){var str=name+"="+encodeURIComponent(value);if(time){var date=new Date(time).toGMTString();str+=";expires="+date}str=domain?str+";domain="+domain:str;str=path?str+";path="+path:str;document.cookie=str}};var urlFilter={config:{url:"",whiteHostList:["m.zhipin.com","www.zhipin.com","pre-www.zhipin.com"],blackPathList:["security-check.html","security-check1.html"]},setStrategy:function(){var url=urlFilter.config.url;switch(true){case urlFilter.isBlackHost(url)||urlFilter.hasBlackPath(url):urlFilter.config.url="/";break}return urlFilter.config.url},isAbsolutePathStartable:function(url){return url.indexOf("//")<0&&url.indexOf("/")===0},isBlackHost:function(url){var isBlackHost=false;var rule=/^(https?)?(:?\/\/+)([^\/?]*)(.*)?$/;url.replace(rule,function(res,$1,$2,$3,$4){isBlackHost=!urlFilter.isHostInWhiteList($3);console.error("hostname",$3,"isBlackHost",isBlackHost);return isBlackHost?"/":url});return isBlackHost},hasBlackPath:function(url){var isBlackPath=false;var blackPathList=urlFilter.config.blackPathList;for(var i=0;i<blackPathList.length;i++){if(url.indexOf(blackPathList)>-1){isBlackPath=true;break}}return isBlackPath},isHostInWhiteList:function(hostname){return urlFilter.config.whiteHostList.indexOf(hostname)>-1},filter:function(url){urlFilter.config.url=url||"/";return urlFilter.setStrategy()}};var jumpReplace=function(url){var filterUrl=urlFilter.filter(url);window.location.replace(filterUrl)};var jumpPage=function(srcReferer,callbackUrl){if(callbackUrl||srcReferer.indexOf("security-check.html")>-1){jumpReplace(callbackUrl)}else{jumpReplace(srcReferer)}var image=new Image;image.src="https://t.zhipin.com/f.gif?pk="+securityPageName+"&ca=securityCheckJump_"+Math.round(((new Date).getTime()-pageStartTime)/1e3)+"&r="+document.referrer};var url=window.location.href;var seed=getQueryString("seed")||"";var ts=getQueryString("ts");var fileName=getQueryString("name");var callbackUrl=getQueryString("callbackUrl");var srcReferer=getQueryString("srcReferer")||"";if(fileName==="null"||!seed||!fileName||!callbackUrl){var fileImage=new Image;fileImage.src="https://t.zhipin.com/f.gif?pk="+securityPageName+"&ca=securityCheckUrlFile&url="+window.location.href}if(seed&&ts&&fileName){var interTimer=setInterval(function(){pageInterNum++;if(pageInterNum>5){clearInterval(interTimer)}var image=new Image;image.src="https://t.zhipin.com/f.gif?pk="+securityPageName+"&ca=securityCheckTimer_"+Math.round(((new Date).getTime()-pageStartTime)/1e3)+"&r="+document.referrer},1e4);seriesLoadScript("security-js/"+fileName+".js",function(){var expiredate=(new Date).getTime()+32*60*60*1e3*2;var code="";var nativeParams={};var ABC=window.ABC||frame.contentWindow.ABC;try{code=(new ABC).z(seed,parseInt(ts)+(480+(new Date).getTimezoneOffset())*60*1e3)}catch(e){}if(code&&callbackUrl){Cookie.set("__zp_stoken__",code,expiredate,COOKIE_DOMAIN,"/");if(typeof window.wst!="undefined"&&typeof wst.postMessage=="function"){nativeParams={name:"setWKCookie",params:{url:COOKIE_DOMAIN,name:"__zp_stoken__",value:encodeURIComponent(code),expiredate:expiredate,path:"/"}};window.wst.postMessage(JSON.stringify(nativeParams))}jumpPage(srcReferer,callbackUrl)}else{var nocodeImage=new Image;nocodeImage.src="https://t.zhipin.com/f.gif?pk="+securityPageName+"&ca=securityCheckNoCode_"+Math.round(((new Date).getTime()-pageStartTime)/1e3)+"&r="+document.referrer;jumpReplace("/")}})}}var ie=!!(window.attachEvent&&!window.opera);var wk=/webkit\/(\d+)/i.test(navigator.userAgent)&&RegExp.$1<525;var fn=[];var run=function(){for(var i=0;i<fn.length;i++)fn()};function ready(f){if(!ie&&!wk&&document.addEventListener)return document.addEventListener("DOMContentLoaded",f,false);if(fn.push(f)>1)return;if(ie)(function(){try{document.documentElement.doScroll("left");run()}catch(err){setTimeout(arguments.callee,0)}})();else if(wk)var t=setInterval(function(){if(/^(loaded|complete)$/.test(document.readyState))clearInterval(t),run()},0)}ready(function(){var na=window.navigator.userAgent.toLowerCase();if(na.match(/micromessenger/i)=="micromessenger"||na.match(/wkwebview/i)=="wkwebview"){init(document.getElementsByTagName("head").item(0));return}var frame=document.createElement("iframe");frame.style.height=0;frame.style.width=0;frame.style.margin=0;frame.style.padding=0;frame.style.border="0 none";frame.name="zhipinFrame";frame.src="about:blank";if(frame.attachEvent){frame.attachEvent("onload",function(){init(frame)})}else{frame.onload=function(){init(frame)}}(document.body||document.documentElement).appendChild(frame)})})();var _hmt=_hmt||[];(function(){var hm=document.createElement("script");hm.src="https://hm.baidu.com/hm.js?194df3105ad7148dcf2b98a91b5e727a";var s=document.getElementsByTagName("script");s.parentNode.insertBefore(hm,s)})();
</script>
</body>
</html>
9582
进程已结束,退出代码为 0
https://www.zhipin.com/c100010000-p10000010/?ka=major_filter_job_10000010_click
我就爬了一下把我的ip封了,我想问一下大佬们,我要是换个请求头还能不能访问啊,这个请求头和ip有关系吗
或者有没有免费的代{过}{滤}理ip可以用的啊 应该是参数少了 带上你的cookie Prozacs 发表于 2022-5-27 14:42
带上你的cookie
OK了OK了谢谢大佬
header什么带齐,让服务器检测出来和浏览器没差别就行了 天使3号 发表于 2022-5-27 15:34
header什么带齐,让服务器检测出来和浏览器没差别就行了
我带齐了,但是我刚刚就爬了一下是可以的,但是不知道为什么boss直聘把我ip封了
BSCEO 发表于 2022-5-27 16:08
我带齐了,但是我刚刚就爬了一下是可以的,但是不知道为什么boss直聘把我ip封了
没IP池就不要玩boss了。反爬很严重的。cookie的__zp_stoken__也需要你逆JS,新手不适合去搞 Prozacs 发表于 2022-5-27 16:23
没IP池就不要玩boss了。反爬很严重的。cookie的__zp_stoken__也需要你逆JS,新手不适合去搞
好的大哥,我知道了,我去找找别的网站 BSCEO 发表于 2022-5-27 16:25
好的大哥,我知道了,我去找找别的网站
搞搞pc百度翻译的sign 网易云音乐的加密。从简单的开始,不会调试百度一下,多的是
页:
[1]
2