My background in test automation is based on using Selenium WebDriver and Java. Since JavaScript has been widely used for testing Web applications, I have decided to investigate tools currently available on the market. I will use these tools to make different scripts and hence find their advantages and disadvantages.

I have investigated the following tools and syntax for automation:
- Selenium Webdriver + Java
- Selenium WebDriver + Cucumber + Java
- Selenium WebDriver + Jasmine syntax for JavaScript applications
- Selenium WebDriver + Mocha syntax for JavaScript applications
- Cypress
- Selenium WebDriver + Protractor
- Selenium WebDriver + NightWatch
- Selenium WebDriver + WebDriverIO
使用 selenium 模拟浏览器进行数据抓取无疑是当下最通用的数据采集方案,它通吃各种数据加载方式,能够绕过客户 JS 加密,绕过爬虫检测,绕过签名机制。它的应用,使得许多网站的反采集策略形同虚设。由于 selenium 不会在 HTTP 请求数据中留下指纹,因此无法被网站直接识别和拦截。

这是不是就意味着 selenium 真的就无法被网站屏蔽了呢?非也。selenium 在运行的时候会暴露出一些预定义的 JavaScript 变量(特征字符串),例如"window.navigator.webdriver",在非 selenium 环境下其值为 undefined,而在 selenium 环境下,其值为 true(如下图所示为 selenium 驱动下 Chrome 控制台打印出的值)。
本文是一个较为完整的 Mitmproxy 教程,侧重于介绍如何开发拦截脚本,帮助读者能够快速得到一个自定义的代理工具。
本文假设读者有基本的 python 知识,且已经安装好了一个 Python3 开发环境。

mitmproxy 是一个命令行下的强大抓包工具,可以在命令行下抓取 HTTP(S) 数据包并加以分析;对于 HTTPS 抓包,首先要在本地添加 mitmproxy 的根证书,然后 mitmproxy 通过以下方式进行抓包

在微服务架构大行其道的今天,对于将程序进行嵌套调用的做法其实并不可取,甚至显得有些愚蠢。但有时候确实要面对这个问题,恰好我在项目中就遇到了这个问题,需要在 Java 程序中调用 Python 程序。关于在 Java 中调用 Python 程序的实现,根据不同的用途可以使用多种不同的方法,在这里就将在 Java 中调用 Python 程序的方式做一个总结。

方法一、直接通过 Runtime 进行调用,方法二、通过 Jython 调用。