看到论坛之前有人提问过,最近正好我也在研究
需要用到mitmproxy,和一点点js技巧
from mitmproxy import ctx
injected_javascript = ‘’’
// overwrite the languages
property to use a custom getter
Object.defineProperty(navigator, “languages”, {
get: function() {
return [“zh-CN”,“zh”,“zh-TW”,“en-US”,“en”];
}
});
// Overwrite the plugins
property to use a custom getter.
Object.defineProperty(navigator, ‘plugins’, {
get: () => [1, 2, 3, 4, 5],
});
// Pass the Webdriver test
Object.defineProperty(navigator, ‘webdriver’, {
get: () => false,
});
// Pass the Chrome Test.
// We can mock this in as much depth as we need for the test.
window.navigator.chrome = {
runtime: {},
// etc.
};
// Pass the Permissions Test.
const originalQuery = window.navigator.permissions.query;
window.navigator.permissions.query = (parameters) => (
parameters.name === ‘notifications’ ?
Promise.resolve({ state: Notification.permission }) :
originalQuery(parameters)
);
‘’’
def response(flow):
# Only process 200 responses of HTML content.
if not flow.response.status_code == 200:
return
# Inject a script tag containing the JavaScript.
html = flow.response.text
html = html.replace('<head>', '<head><script>%s</script>' % injected_javascript)
flow.response.text = str(html)
ctx.log.info('>>>> js代码插入成功 <<<<')
亲测可以过淘宝的检测,从js代码来看算是比较通用的解法,特定网站思路其实类似