我在使用 Selenium WebDriver.chromedriver 获取 json 结果数据时遇到问题,服务器将响应 http 状态代码 429 太多请求。但是当我直接使用 chrome 来获取这个网址“ https://shop.coles.com.au/search/resources/store/20501/productview/2364711P ”时,它会正常工作。我想在服务器端有一些验证逻辑,但是如何交叉,请帮助非常感谢~
我明白了为什么通过服务器阻止下面的这个 js 代码检测到我使用 webdriver 然后阻止我,然后不创建 cookie ..
"use strict";
!function() {
function e(e) {
var r = (void 0 !== e.stack ? e.stack : "").replace(/"/g, '"')
, t = {
stack: r,
message: e.message,
name: e.name
};
(new Image).src = l + "/error?e=" + encodeURIComponent(JSON.stringify(t)),
console.log("Error", "\n name: " + t.name, "\n message: " + t.message, "\n stack: " + t.stack)
}
function r(e) {
return "true" === e
}
function t(e) {
return void 0 !== e && e.indexOf("canvas") > -1
}
function n(e) {
return void 0 !== e.ActiveXObject && null !== e.ActiveXObject
}
function a(e) {
return void 0 !== e.Fingerprint2 && null !== e.Fingerprint2
}
function i(e) {
return null !== ("" + e.userAgent).match(/PhantomJS/)
}
function o(e) {
return void 0 !== e.webdriver
}
function c(e) {
try {
return e.appName = "Chrome macIntel IE",
"Chrome macIntel IE" === e.appName
} catch (e) {
return !1
}
}
function s(e) {
var r = o(e.navigator) && !1 !== e.navigator.webdriver
, t = "webdriver"in e
, n = "true" === document.getElementsByTagName("html")[0].getAttribute("webdriver");
return r || t || n
}
function u(e) {
try {
return (0,
(0,
e.constructor.constructor)("return process")().mainModule.require)("fs"),
!0
} catch (e) {
return !1
}
}
function tEibEnv() {
var e = ["stack", "stackTrace", "description"];
try {
[]()[[+[]] + []]
} catch (r) {
return void 0 !== r[e[0]] ? r[e[0]] : void 0 !== r[e[1]] ? r[e[1]] : void 0 !== r[e[2]] ? r[e[2]] : ""
}
}
function I() {
if ("undefined" == typeof XMLHttpRequest)
try {
return new ActiveXObject("Msxml2.XMLHTTP.6.0")
} catch (e) {
try {
return new ActiveXObject("Msxml2.XMLHTTP.3.0")
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
throw new Error("AJAX requests appear to be unsupported by this browser")
}
}
}
return new XMLHttpRequest
}
function E(e, r) {
for (var t in r)
if (Object.prototype.hasOwnProperty.call(r, t)) {
var n = r[t];
void 0 !== n && e.setRequestHeader(t, n)
}
return e
}
function d(e, r, t, n, a) {
try {
var i = I();
i.open(r, e, !0),
void 0 !== t.headers && E(i, t.headers),
i.onreadystatechange = function() {
if (4 === i.readyState) {
var e = "" + i.status;
if ("4" === e.charAt(0) || "5" === e.charAt(0))
return void n(new Error("Error issuing AJAX request (status code: " + e + ")"));
a(i.responseText)
}
}
,
i.send(t.body)
} catch (e) {
n(e)
}
}
function N(e, r, t, n) {
var a = n;
try {
d(l, "POST", {
headers: {
"Content-Type": "application/json; charset=utf-8"
},
body: JSON.stringify({
t: e,
d: r
})
}, t, function(e) {
try {
a(JSON.parse(e))
} catch (e) {
t(e)
}
})
} catch (e) {
t(e)
}
}
function _(e, r, t, a, o, I, E, d, _, v, l) {
var f = window
, R = window.navigator
, L = {
a719076e644f9e643a85b5c16b391623abd18d1b37c4b5629c4de8f2f01b4704f: e,
ab78473b1c731bfc01032f3ee7df063b3fd085b3ba6c9eb186df3ed4f92442b1a: r,
a6c7ed91d806b6bb3b5a3bdcc4091c4f8dc081db7ffc0831f955e2bcb3aab7355: t,
a061a12d2fd8497ae57a06624b04b9c7faa35b77b803402a0da22f03b78e99a62: a,
a2159e86126934a65811ace05974f8a36ae2b6d5de0bbf5824d3605e5d7077ab4: o,
af5ea0bb3bdbaa142a206ed65324c1eb45469bf2cabbecdc7a180d27a49332bac: I,
ab47f0a3cf8da04ff7dd6196f6ae6a06b906bc4a0b30cfc71c2730bb70efd2940: E,
ab9cec510ce9fb76e79882a7f612275b083c607c17fe9dd44438da49625c08cfc: void 0 !== d ? d : [],
a89ee5f18b07459773463dfd370524376e8b4d997c13436c62b763cc649f548ea: void 0 !== _ ? _ : [],
a083c50eb73edc35f752e1b1d3925114d5a53f93352752e88d87e13f9432b05ce: tEibEnv(),
ac54ffdaf47ba30b6e1c02994c2a77cd822c023cf55c8679fcd2b1e722a33fd88: u(f),
a14559ea59a0352ae64faa9bbc92eec821130e9b560f420bb16d8542699952a87: s(f),
a8d2114495f1bc2c3adeb4a7f0e99553e252ad79a39ad72c0be1f1ebdf3cf1cdb: void 0 !== R && i(R),
a701bb64a76ab3877ebf146a5dd709778eb2fc99de0005972eda2dae28dc12fb7: void 0 !== R && c(R),
ac57c5637ca15e2901d75b3953d35d492e6c700a554e58cf00f302d8ab82d0ac4: n(f)
};
N(T, L, v, l)
}
function v(n) {
(new (0,
n.Fingerprint2)).get(function(n, a) {
for (var i = {}, o = 0; o < a.length; o++) {
var c = a[o];
i[c.key] = c.value
}
_(n, i.user_agent, r(i.has_lied_browser), r(i.has_lied_os), r(i.adblock), t(i.canvas), i.available_resolution, i.regular_plugins, i.ie_plugins, e, function(e) {
e.redirect && window.location.reload(!0)
})
})
}
var l = "/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/fingerprint"
, T = "94dbc0cc-d783-c10b-3612-c657311fecb9";
if (a(window))
try {
v(window)
} catch (r) {
e(r)
}
else
!function(e, r, t, n) {
var i = e
, o = setInterval(function() {
return i <= 0 ? (clearInterval(o),
t(new Error("Library is not defined"))) : a(window) ? (clearInterval(o),
n(window)) : void (i -= 1)
}, r)
}(100, 100, function(r) {
e(r)
}, function(r) {
try {
v(r)
} catch (r) {
e(r)
}
})
}();
//# sourceMappingURL=fingerprint.js.map