一个高级Twitter抓取与OSINT工具。
项目描述
TWINT - Twitter情报工具
无需身份验证。无需API。无限制。
Twint是一个用Python编写的Twitter高级抓取工具,允许从Twitter个人资料抓取推文,而无需使用Twitter API。
Twint利用Twitter的搜索运算符,让您能够抓取特定用户的推文,抓取与特定主题、标签和趋势相关的推文,或从推文中筛选出敏感信息,如电子邮件和电话号码。我认为这非常实用,您也可以发挥创意。
Twint还对Twitter进行特殊查询,允许您抓取Twitter用户的关注者、用户喜欢的推文以及他们关注的人,而无需任何身份验证、API、Selenium或浏览器模拟。
tl;dr 优势
使用Twint与Twitter API相比的一些优势
- 可以获取几乎所有推文(Twitter API限制为最后3200条推文);
- 快速初始设置;
- 可以匿名使用,无需Twitter注册;
- 无速率限制.
Twitter施加的限制
Twitter限制了浏览用户时间线时的滚动。这意味着您将能够通过.Profile
或.Favorites
获取约3200条推文。
要求
- Python 3.6;
- aiohttp;
- aiodns;
- beautifulsoup4;
- cchardet;
- elasticsearch;
- pysocks;
- pandas (>=0.23.0);
- aiohttp_socks;
- schedule;
- geopy;
- fake-useragent;
- py-googletransx.
安装
Git
git clone https://github.com/twintproject/twint.git
cd twint
pip3 install . -r requirements.txt
Pip
pip3 install twint
或
pip3 install --user --upgrade -e git+https://github.com/twintproject/twint.git@origin/master#egg=twint
Pipenv:
pipenv install -e git+https://github.com/twintproject/twint.git#egg=twint
CLI基本示例和组合
一些简单的示例,帮助您了解基础知识
twint -u username
- 从用户的时间轴抓取所有推文。twint -u username -s pineapple
- 从用户的时间轴抓取包含菠萝的推文。twint -s pineapple
- 从所有人的推文中收集包含菠萝的每条推文。twint -u username --year 2014
- 收集在2014年之前发表的推文。twint -u username --since "2015-12-20 20:30:15"
- 收集自2015-12-20 20:30:15以来发表的推文。twint -u username --since 2015-12-20
- 收集自2015-12-20 00:00:00以来发表的推文。twint -u username -o file.txt
- 抓取推文并保存到file.txt。twint -u username -o file.csv --csv
- 抓取推文并将其保存为csv文件。twint -u username --email --phone
- 显示可能包含电话号码或电子邮件地址的推文。twint -s "Donald Trump" --verified
- 显示关于Donald Trump的认证用户发表的推文。twint -g="48.880048,2.385939,1km" -o file.csv --csv
- 从巴黎某地1公里范围内的推文,并导出到csv文件。twint -u username -es localhost:9200
- 将推文输出到Elasticsearch。twint -u username -o file.json --json
- 抓取推文并将其保存为json文件。twint -u username --database tweets.db
- 将推文保存到SQLite数据库。twint -u username --followers
- 抓取Twitter用户的关注者。twint -u username --following
- 抓取Twitter用户所关注的人。twint -u username --favorites
- 收集用户喜欢的所有推文(收集约3200条推文)。twint -u username --following --user-full
- 收集用户关注的完整用户信息。twint -u username --profile-full
- 使用一种缓慢但有效的方法收集用户个人资料中的推文(收集约3200条推文,包括转发)。twint -u username --retweets
- 使用一种快速方法收集用户个人资料中的最后900条推文(包括转发)。twint -u username --resume resume_file.txt
- 从最后一个保存的scroll-id开始恢复搜索。
有关命令和选项的更多详细信息请参阅wiki。
模块示例
Twint现在可以作为模块使用并支持自定义格式。更多详细信息请参阅wiki。
import twint
# Configure
c = twint.Config()
c.Username = "now"
c.Search = "fruit"
# Run
twint.run.Search(c)
输出
955511208597184512 2018-01-22 18:43:19 GMT <now> 菠萝是最好的水果
import twint
c = twint.Config()
c.Username = "noneprivacy"
c.Custom["tweet"] = ["id"]
c.Custom["user"] = ["bio"]
c.Limit = 10
c.Store_csv = True
c.Output = "none"
twint.run.Search(c)
存储选项
- 写入文件;
- CSV;
- JSON;
- SQLite;
- Elasticsearch。
Elasticsearch设置
有关使用Twint设置Elasticsearch的详细信息请参阅wiki。
图形可视化
我们正在开发Twint桌面应用程序。
常见问题解答
我尝试从用户那里抓取推文,我知道它们存在,但我没有收到它们
Twitter可以实施影子封禁,这意味着他们的推文将无法通过搜索获取。为了解决这个问题,如果您通过CLI使用Twint,请传递--profile-full
,如果您将Twint作为模块使用,请添加config.Profile_full = True
。请注意,此过程将非常缓慢。
更多示例
关注者/关注
仅获取关注者用户名/关注用户名
twint -u username --followers
twint -u username --following
获取关注者/关注用户的用户信息
twint -u username --followers --user-full
twint -u username --following --user-full
用户列表
获取特定用户的信息
twint -u username --user-full
从用户列表获取用户信息
twint --userlist 输入列表 --user-full
推文翻译(实验性)
获取100条英文推文并将它们翻译成意大利语
twint -u noneprivacy --csv --output none.csv --lang en --translate --translate-dest it --limit 100
或
import twint
c = twint.Config()
c.Username = "noneprivacy"
c.Limit = 100
c.Store_csv = True
c.Output = "none.csv"
c.Lang = "en"
c.Translate = True
c.TranslateDest = "it"
twint.run.Search(c)
注意事项
精选博客文章
联系方式
如果您有任何问题,想加入讨论,或需要额外帮助,欢迎加入我们的Twint专用频道 OSINT团队
项目详情
twint-2.1.20.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b3b7671997e31ea5dff9f4cca0f83add07c3163fd7ab1dc8e44f9110eeb1965d |
|
MD5 | 6750dbf97206a88e924ed627fbd8b22a |
|
BLAKE2b-256 | 69e14daa62fbae8a34558015c227a8274bb2598e0fc6e330bdeb8484ed154ce7 |