当前位置: 移动技术网 > IT编程>脚本编程>Python > 使用 mitmdump 进行 selenium webDriver绕过网站反爬服务的方法 pdd某宝 可用

使用 mitmdump 进行 selenium webDriver绕过网站反爬服务的方法 pdd某宝 可用

2019年12月19日  | 移动技术网IT编程  | 我要评论

科洛弗档案2,终结者5(创世纪)电影,动画片下载网站免费

安装:  pip install  mitmproxy

新建一个脚本

脚本代码:

 1 from mitmproxy import ctx
 2 
 3 injected_javascript = '''
 4 // overwrite the `languages` property to use a custom getter
 5 object.defineproperty(navigator, "languages", {
 6   get: function() {
 7     return ["zh-cn","zh","zh-tw","en-us","en"];
 8   }
 9 });
10 // overwrite the `plugins` property to use a custom getter.
11 object.defineproperty(navigator, 'plugins', {
12   get: () => [1, 2, 3, 4, 5],
13 });
14 // pass the webdriver test
15 object.defineproperty(navigator, 'webdriver', {
16   get: () => false,
17 });
18 // pass the chrome test.
19 // we can mock this in as much depth as we need for the test.
20 window.navigator.chrome = {
21   runtime: {},
22   // etc.
23 };
24 // pass the permissions test.
25 const originalquery = window.navigator.permissions.query;
26 window.navigator.permissions.query = (parameters) => (
27   parameters.name === 'notifications' ?
28     promise.resolve({ state: notification.permission }) :
29     originalquery(parameters)
30 );
31 '''
32  
33 def response(flow):
34     # only process 200 responses of html content.
35     if not flow.response.status_code == 200:
36         return
37  
38     # inject a script tag containing the javascript.
39     html = flow.response.text
40     html = html.replace('<head>', '<head><script>%s</script>' % injected_javascript)
41     flow.response.text = str(html)
42     ctx.log.info('插入成功 ')
43  

然后运行mitmdump 

mitmdump -s xxxx.py 

默认为8080端口,将webdriver设置代理127.0.0.1:8080

然后就能监听和修改selenium特征了。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网