Scraping twitter content from twitter streaming API, in python3.
このレポジトリは,Marsam-Ma-zz/twitter_scraperを日本語リプライ収集用に独自改良したものです.
ChatBot,クソリプ収集目的等にご利用ください.
- Twitter Streaming API
- Python 3.6+
- Twitter API tokens を入手.
config.yml.default
をコピーしてconfig.yml
を作成.config.yml
に 1. で入手した自分の tokens をそれぞれ記入.pip install -r requirments.txt
screen
コマンド等を用いると便利です.
python twitter.py
corpus/ja_YYYYMMDD_HHMMSS.txt
に保存されます.
また,このスクリプトは問題が発生する限り半永久的に収集しますのでご注意ください.
(例) 実際には日本語
Line number | Sentences |
---|---|
1 | 誕生日おめでとう! |
2 | ありがとう! |
3 | おはようー |
4 | おは! |
それぞれ
Line number(1,2),(3,4) がそれぞれ独立した会話のペアになっており,
奇数行が発言,偶数行がそれに対する返信となっています.
stream.filterを用いて監視を行います.
track
に指定した文字列により,指定の検索ワードでストリーミングが行えます.
デフォルトでは,
track=['私','あなた','俺','ー','する','です','ます','けど','何','@', '#', '#', '。', ',', '!','?','…', '.', '!','?', ',', ':', ':', '』', ')', ')', '...']
という適当な文字列を指定しています.
さらに自分でフィルターを改良することができます.
詳しくは公式ガイドを参照ください.