通过滚动行为检测爬虫机器人
Detecting scraper bots through scroll behaviour

原始链接: https://niki.cat/detecting-scraper-bots-through-scroll-behaviour

这项研究探讨了利用戈(Goh)和巴拉巴西(Barabási)提出的“突发性”(Burstiness)和“记忆性”(Memory)概念,来区分人类网络行为与人工智能机器人。以往通过请求时间戳识别机器人的尝试,往往无法捕捉到能够模拟浏览器行为的高级代理,而作者发现人类的滚动行为是一种独特且难以模仿的模式。 通过将这些指标应用于“FP-Agent”数据集,作者发现人类滚动事件的突发性显著高于大多数机器人,而记忆性则较低。仅使用这两个特征训练的 LightGBM 模型达到了 73.4% 的准确率,但在区分人类与 ChatGPT 代理时表现较弱。 作者总结认为,虽然滚动行为是一种有前景的预测指标,但在内容密集的网站上应用最为有效。这种方法是一个模块化的构建基块;作者计划通过整合鼠标移动轨迹和打字动态等额外行为特征,来增强未来的机器人检测模型。

这篇 Hacker News 讨论探讨了网站通过行为分析(如滚动和鼠标轨迹)检测爬虫机器人与开发者反制手段之间的“军备竞赛”。 参与者分享了机器人开发的个人经验,详细介绍了模拟随机鼠标移动、变速打字、类人滚动等规避检测的高级技术。然而,也有人指出这些努力往往属于过度设计,因为许多系统并未实现如此细致的分析。 讨论转向了更广泛的影响: * **经济激励**:网站面临两难抉择:一方面希望拦截机器人以节省带宽和保护内容,另一方面又需对机器人保持“友好”,以便利自动化电子商务采购的 AI 代理。 * **广告欺诈**:参与者讨论了机器人流量如何影响 Google 广告,一些人认为无论实际人类交互如何,高机器人比例已被计入竞价之中。 * **隐私顾虑**:批评者认为,依赖客户端 JavaScript 执行来检测“人类特征”,会损害那些禁用脚本或注重隐私的用户的体验,仅仅因为他们不符合标准的可追踪行为,就被打上“机器人”的标签。共识反映了人们对现代网络中日益严苛、反用户的监控技术的不满。
相关文章

原文

Ever since I first read "Burstiness and Memory in Complex Systems" by Kwang-Il Goh, I have been obsessed with the two formulas showcased in the paper. Burstiness (B), and its just-as-important counterpart Memory (M), let us understand the dynamics of event-based systems. 

We can use them to analyse the behaviour of sent emails, texts or even heartbeats when only the time at which those events happened is known. This allows us to clearly establish which patterns are human-like and which aren't based on a dataset of already classified data. We know humans reply to texts in a bursty manner (the time they take to answer is not uniform) while simple bots respond as fast as possible, thus they have different B and M coefficients.

Goh, K.-I., & Barabási, A.-L. (2008), Figure 4

In previous personal research, I used these two values to differentiate between human and bot sessions based on the timings of their requests, which usually worked, nonetheless, this approach identified sessions as human if they were sent from any browser that loaded CSS and JS files, allowing more advanced bots like ClaudeBot to appear human by using a headless browser. It essentially distinguished between crafted requests versus requests sent from a real browser, instead of bot and human.

The scroll wheel

Some time ago I noticed a distinctly human behaviour that I believe cannot be easily imitated by bots, scrolling. When I am scrolling a page looking for information using the scroll wheel, I usually don't scroll down linearly until I find what I am looking for, instead, I do so with a bursty pattern. For example, that pattern might more closely resemble time series a or e rather than c.

Goh, K.-I., & Barabási, A.-L. (2008), Figure 1

I think most scraping bot developers still haven't honed their scrolling pattern, so I decided to test if burstiness and memory applied to the inter-event times of scroll events were variables that could have predictive power in a machine learning model, in order to distinguish between humans and bots.

To do so, I used the dataset provided by the paper "FP-Agent: Fingerprinting AI Browsing Agents" by Ethan Wang, et al., in which the authors explained the process of how they created a machine learning model that could distinguish between different AI browsing agents in a controlled environment (a website made specifically for the purpose). They recorded data of different agents and humans navigating through their website. Their model gave good results, but I don't think it would be effective in a real-world setting when applied to different websites, which involves lots of variation. Nevertheless, they made the dataset available for download on OSF.io.

I calculated the burstiness and memory values for the JavaScript "scroll" events of each agent in each page (one burstiness and memory value per page visited). These are the results:

We can observe that the human distribution is clearly different from the other agents', presenting a higher Burstiness coefficient and almost no Memory; the only agent that sometimes resembles humans is ChatGPT Agent. This data seems promising, but to further prove if the two values have predictive value I trained a LightGBM (decision tree gradient boosting) model to classify each single-page interaction.

The model only had two features available, B and M, and it had to predict which agent performed the interactions. The result was an accuracy of 73.4%, which is not that bad. As expected, the model mainly confused Humans and ChatGPT Agent, most likely due to low feature count or a small dataset (~150 data points per agent is too small), the model would need other features to be able to distinguish them further.

Conclusion

Scroll behaviour seems to be a relevant data point for distinguishing bots from humans, and Burstiness and Memory have proven to have predictive power in a controlled environment. This approach will obviously not be effective on websites that don't require scrolling; on the other hand, blogging or information sites like Wikipedia are the ones most able to take advantage of this method.

The model shown in this blog post is not accurate enough, though, if combined with more features extracted from other actions such as mouse movement or typing, I believe it is possible to create a general model capable of protecting websites from scraper bots.

I will keep posting my research in this website. Next up, I will be taking a look at mouse movement patterns.

联系我们 contact @ memedata.com