[论文解读] A Web Scraping Methodology for Bypassing Twitter API Restrictions
作者提出了一种基于 Scrapy 的网页抓取方法,用于在超出 API 限制的情况下收集历史 Twitter 数据,配备 Django UI 和 Scrapyd 以实现可扩展抓取。
Retrieving information from social networks is the first and primordial step many data analysis fields such as Natural Language Processing, Sentiment Analysis and Machine Learning. Important data science tasks relay on historical data gathering for further predictive results. Most of the recent works use Twitter API, a public platform for collecting public streams of information, which allows querying chronological tweets for no more than three weeks old. In this paper, we present a new methodology for collecting historical tweets within any date range using web scraping techniques bypassing for Twitter API restrictions.
研究动机与目标
- 说明在 API 约束之外,为 NLP、ML 和情感分析所需的历史 Twitter 数据的需求。
- 提出一种网页抓取方法,利用 Twitter Search 端点在较长日期范围内收集大量推文。
- 展示一个可部署、实现守护进程化的系统,具有用于启动和监控抓取任务的 GUI。
提出的方法
- 使用带有自定义 HTTP 头的 Twitter Search 端点来构建高级查询。
- 实现一个基于 Scrapy 的爬虫,从 HTML 载荷中提取推文并解析推文字段。
- 使用两端点策略:初始搜索端点和用于获取较早结果的二级时间线端点(通过 maximum-position)。
- 使用 maximum-position 值进行迭代分页,以检索多轮推文。
- 提供命令行界面和绑定到 scrapyd 的 Django GUI,以实现守护进程化、计划任务的抓取。
- 通过 Scrapy 管道将检索到的推文存储到关系型或非关系型数据库中。
实验结果
研究问题
- RQ1是否可以通过对公开搜索端点的网页爬取,在标准的三周窗口之外检索历史推文?
- RQ2基于 Scrapy 的管道在跨越扩展日期范围时,如何有效地收集和处理带分页的推文?
- RQ3在总推文量、时间和覆盖范围方面,Twitter API 与网页抓取方法之间的性能权衡是什么?
- RQ4GUI 与守护进程化架构是否能简化大规模、可重复的推文数据收集?
主要发现
- Twitter Scrapy 在同一日期范围内检索 48,929 条推文 vs 46,000 条 Twitter API Stream,在总用时从 1800s 降至 1893s(注:表 3 中给出数值)。
- Twitter Scrapy 排除转发和提及检索 48,601 条推文,耗时 1,021 秒;而 API Search 排除转发和提及检索 47,582 条推文,耗时 2,109 秒。
- 在 9-10-2017 至 19-10-2017 的范围内,Twitter API Search 产生 29,895 条推文,而 Twitter Scrapy 产生 64,531 条推文。
- 该方法使用两个端点和基于 maximum-position 的分页来访问初始结果之外的较早推文。
- 一个带有 Scrapyd 守护进程的 Django GUI 能在 EC2 环境中实现抓取任务的调度、监控和部署。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。