一:前言
這是之前爬蟲(chóng)時(shí)候的記錄筆記问词,以后方便查看哄尔。
使用方法:
- 1.調(diào)用node.js 去執(zhí)行即可籽慢。比如這個(gè)文件名是 signature.js, 執(zhí)行代碼:
node signature.js
- python 程序里面調(diào)用node執(zhí)行js文件,然后把讀出來(lái)的參數(shù)返回給相關(guān)函數(shù)就可以爬了:
acc = subprocess.Popen('node signature.js', stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd='')
aac.wait()
resulet = aac.stdout.read()
但是比較關(guān)鍵的是要加入navigator.userAgent
常見(jiàn)的js加密里面有很多參數(shù)要注意保留比如 document,navigator,location
當(dāng)然頭條爬蟲(chóng)入口有很多舶衬,也不用只局限于此重贺,比如...(嘿嘿不說(shuō)了耿导,自己嘗試吧)
二:實(shí)戰(zhàn)代碼
navigator = {};
navigator.userAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
Function(function(t) {
return '?e(e,a,r){?(b[e]||(b[e]=t("x,y","?x "+e+" y"?)(r,a)}?a(e,a,r){?(k[r]||(k[r]=t("x,y","?new x[y]("+Array(r+1).join(",x[?y]")?(1)+")"?)(e,a)}?r(e,a,r){?n,t,s={},b=s.d=r?r.d+1:0;for(s["$"+b]=s,t=0;t<b;t?)s[n="$"+t]=r[n];for(t=0,b=s?=a?;t<b;t?)s[t]=a[t];?c(e,0,s)}?c(t,b,k){?u(e){v[x?]=e}?f?{?g=?,t?ing(b?g)}?l?{try{y=c(t,b,k)}catch(e){h=e,y=l}}for(?h,y,d,g,v=[],x=0;;)switch(g=?){case 1:u(!?)?4:?f??5:u(?(e){?a=0,r=e?;???{?c=a<r;?c&&u(e[a?]),c}}(???6:y=?,u(?(y??8:if(g=?,l??g,g=?,y===c)b+=g;else if(y!==l)?y?9:?c?10:u(s(???11:y=?,u(?+y)?12:for(y=f?,d=[],g=0;g<y?;g?)d[g]=y.charCodeAt(g)^g+y?;u(String.fromCharCode.apply(null,d??13:y=?,h=delete ?[y]?14:???59:u((g=?)?(y=x,v.slice(x-=g,y?:[])?61:u(?[?])?62:g=?,k[0]=65599*k[0]+k[1].charCodeAt(g)>>>0?65:h=?,y=?,?[y]=h?66:u(e(t[b?],?,???67:y=?,d=?,u((g=?).x===c?r(g.y,y,k):g.apply(d,y??68:u(e((g=t[b?])<"<"?(b--,f?):g+g,?,???70:u(!1)?71:?n?72:?+f??73:u(parseInt(f?,36??75:if(?){b??case 74:g=?<<16>>16?g?76:u(k[?])?77:y=?,u(?[y])?78:g=?,u(a(v,x-=g+1,g??79:g=?,u(k["$"+g])?81:h=?,?[f?]=h?82:u(?[f?])?83:h=?,k[?]=h?84:?!0?85:?void 0?86:u(v[x-1])?88:h=?,y=?,?h,?y?89:u(??{?e?{?r(e.y,arguments,k)}?e.y=f?,e.x=c,e}?)?90:?null?91:?h?93:h=??0:??;default:u((g<<16>>16)-16)}}?n=this,t=n.Function,s=Object.keys||?(e){?a={},r=0;for(?c in e)a[r?]=c;?a?=r,a},b={},k={};?r'.replace(/[?-?]/g, function(e) {
return t[15 & e.charCodeAt(0)]
})
}("v[x++]=?v[--x]?t.charCodeAt(b++)-32?function ?return ?))?++?.substr?var ?.length?()?,b+=?;break;case ?;break}".split("?")))()('gr$Daten Иb/s!l y?y?g,(lfi~ah`{mv,-n|jqewVxp{rvmmx,&eff?kx[!cs"l".Pq%widthl"@q&heightl"vr*getContextx$"2d[!cs#l#,*;?|u.|uc{uq$fontl#vr(fillTextx$$龘???2<[#c}l#2q*shadowBlurl#1q-shadowOffsetXl#$$limeq+shadowColorl#vr#arcx88802[%c}l#vr&strokex[ c}l"v,)}eOmyoZB]mx[ cs!0s$l$Pb<k7l l!r&lengthb%^l$1+s$j?l s#i$1ek1s$gr#tack4)zgr#tac$! +0o![#cj?o ]!l$b%s"o ]!l"l$b*b^0d#>>>s!0s%yA0s"l"l!r&lengthb<k+l"^l"1+s"j?l s&l&z0l!$ +["cs\'(0l#i\'1ps9wxb&s() &{s)/s(gr&Stringr,fromCharCodes)0s*yWl ._b&s o!])l l Jb<k$.aj;l .Tb<k$.gj/l .^b<k&i"-4j!?+& s+yPo!]+s!l!l Hd>&l!l Bd>&+l!l <d>&+l!l 6d>&+l!l &+ s,y=o!o!]/q"13o!l q"10o!],l 2d>& s.{s-yMo!o!]0q"13o!]*Ld<l 4d#>>>b|s!o!l q"10o!],l!& s/yIo!o!].q"13o!],o!]*Jd<l 6d#>>>b|&o!]+l &+ s0l-l!&l-l!i\'1z141z4b/@d<l"b|&+l-l(l!b^&+l-l&zl\'g,)gk}ejo{?cm,)|yn~Lij~em["cl$b%@d<l&zl\'l $ +["cl$b%b|&+l-l%8d<@b|l!b^&+ q$sign ', [TAC = {}]);
keyword = process.argv[2];
var data = TAC.sign(0);
console.log(data);
三:一些常見(jiàn)關(guān)鍵參數(shù)解釋声怔,可能被用來(lái)作為加密或者反爬蟲(chóng)的參數(shù)。
location:
location.href // 全部url
location.search // spm=a21bo.2017.201867-links-3.17.5af911d9SB8rte URL 保留參數(shù)部分 ? 也去掉
location.hash // hash 屬性是一個(gè)可讀可寫(xiě)的字符串舱呻,該字符串是 URL 的錨部分(從 # 號(hào)開(kāi)始的部分)
location.hostname // 返回URL的主機(jī)名
location.protocol // 返回一個(gè)URL協(xié)議 http 還是https
navigator:
navigator.userAgent // userAgent
navigator.getBattery // chrome瀏覽器醋火、安卓的webview悠汽、iphone都可以使用。ie芥驳,safari不管是pc還是移動(dòng)端都不支持 都給
getBattery //電池
navigator.webdriver // 不用賦值 undefined
navigator.language // "zh-CN"
navigator.systemLanguage // 不用賦值 undefined
navigator.vendor // 瀏覽器的品牌 "Google Inc."
navigator.appVersion // 瀏覽器版本 UA去掉 "Mozilla/"
navigator.sgAppName // 不用賦值 undefined
navigator.platform // 瀏覽器平臺(tái) "Win32"