附上范例 想用C#重现这段JS
https://jsfiddle.net/ayfm1bq6/3/
我写了爬虫想爬某个网站
那网站需要按一个按钮 触发JS产生COOKIE
有这COOKIE才能登入
以下是部份的源码
function toNumbers(d) {
var e = [];
d.replace(/(..)/g, function(d) {
e.push(parseInt(d, 16))
});
return e
}
function toHex() {
for (var d = [], d = 1 == arguments.length && arguments[0].constructor =
arguments[0] : arguments, e = "", f = 0; f < d.length; f++) e += (16 > d[f] ? "
return e.toLowerCase()
}
function Decode() {
var a = toNumbers("2c74fc8f6cbd3aac4dbd79d854eee1b0"),
b = toNumbers("5907dbd743bae6749df54fc54f81e447"),
c = toNumbers("7d74f260ffbe6844f2c77cba7446350c");
document.cookie = "verifid=" + toHex(slowAES.decrypt(c, 2, a, b)) + "; max-age=" + 60 * 60 * 24 * 1 + "; path=/";
window.location.href = "http://www.xxxxx.html?attempt=1";
}
按下按钮会呼叫Decode()附加cookie后转页
slowAew是引用这个套件
https://greasyfork.org/zh-TW/scripts/13883-aes-js/code
我试着直接拿手动产生出来的COOKIE可以过
但换了另一台电脑就不行了
看来还是要模拟JS的行为
想问爬虫遇到这种网站要怎么辨呢
GOOGLE不太到解决办法