[問題] 爬蟲遇到slowAes加密的網頁

作者: vi000246 (Vi)   2016-10-21 15:09:19
附上範例 想用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不太到解決辦法
作者: Neisseria (Neisseria)   2016-10-21 18:38:00
可以用 Selenium 之類的軟體去爬網頁Selenium 會開真的瀏覽器去爬指定的網頁再把爬回來的網頁原始碼慢慢解析出要的資料即可
作者: vi000246 (Vi)   2016-10-21 22:14:00
剛研究一下Selenium可以在C#裡使用 我再試試看 感謝

Links booklink

Contact Us: admin [ a t ] ucptt.com