Twitterからのデータ収集は通常、APIが用いられますが、APIにはいくつかの利用制限があることはご存知かと思います。この利用制限を回避できる便利ツールTwitter Scraperを紹介します。
Twitter Scraperの特徴
インストール
pip install twitterscraper
実行例
$ twitterscraper "#MeToo near:Seattle" --limit 100 --poolsize 100 --begindate 2018-01-01 --enddate 2018-08-01 -o tweets.json
収集されたデータの一部
[{ "fullname": "Town Hall Seattle", "html": (略), "id": "967540861700661248", "likes": "1", "replies": "0", "retweets": "0", "text": "While this is not quite #MeToo material, I was told by multiple people that the Seattle\u2026 https://www.instagram.com/p/BfmQfyKluGA/\u00a0", "timestamp": "2018-02-24T23:24:52", "url": "/hotdogjudge/status/967540861700661248", "user": "hotdogjudge"}, ...]
説明
コマンドを見れば大体わかります。検索クエリはTwitterの仕様どおりです。
以下のオプションは省略できます。 --limit 収集数 --poolsize 並列アクセス数 --begindate 取得日の始点 --enddate 取得日の終点 -o ファイル出力
他のオプションもありますが、それについては以下のページを見てください。 https://github.com/taspinar/twitterscraper
まあ、やりすぎればTwitterからブロックされるかもしれません。
参考
[0] https://github.com/taspinar/twitterscraper
追記
2018/08/23 18:17
ScrapyやPortiaを使ったり、Googleから検索結果をスクレイピングしたりと、最近の仕事はスクレイピングが多いです。