通过滚动行为检测爬虫机器人
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 代理开放平台;而另一些公司则采取严厉的封锁措施,以节省带宽并防止被抓取。 用户与 Adafruit 团队之间的一段交流揭示了其中的微妙平衡;企业虽然通过屏蔽爬虫来防止库存囤积,但过于严格的过滤措施可能会在无意中妨碍普通用户和使用 AI 辅助比价的购物者。 许多用户对现代机器人检测机制的“严酷”表示不满,指出这些技术往往依赖于侵入性的 JavaScript 执行,这会对注重隐私或禁用脚本的用户造成影响。另一些人则指出,“机器人”的定义已演变为“无法产生经济效益的访问者”,网站所有者正越来越多地将可变现流量置于开放访问之上。最终,参与者建议理想的解决方案是转向公共 API 和语义网标准,以实现有序的数据访问,而非陷入当前这种机器人行为不断升级与粗暴封锁的循环。
相关文章

原文

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