Dissenter工具包
项目描述
Ressenter
Ressenter是一个命令行工具,用于从Dissenter.com(由Gab.com运营的基于浏览器的社交网络)获取内容。(我们不会给这两个域名提供超链接。)
此工具无需与Dissenter进行任何身份验证;它获取的所有数据都可在公共领域获取。
目前,此工具可以
- 可靠地提取过去七天内Dissenter上发布的所有评论
- 提取当前“热门”评论
- 提取当前“有争议”的评论
- 提取当前趋势URL
- 提取特定URL的所有评论
- 提取特定用户发布的所有评论
鲁棒性
此工具是通过逆向工程Dissenter的API制作的。(公平地说,这并不难。)因为我们没有深入了解Dissenter的内部机制,所以无法保证此工具提供了详尽或可靠的Dissenter内容存档。
例如,我们不知道评论在一段时间后是否会变得不可访问,或者是否有从任何特定用户那里提取评论数量的限制。
用法
Usage: ressenter [OPTIONS] COMMAND [ARGS]...
Options:
--format [jsonl|csv] output format
--help Show this message and exit.
Commands:
comments Pull all the most recent comments
trending Pull the current trending URLs
url Pull comments for a particular URL.
user Pull all the comments of a particular user
Ressenter 可以将数据输出为 jsonl
和 csv
格式(默认为 jsonl
)。只需在子命令前传递 --format
选项(例如,ressenter --format=csv comments
)。所有数据目前都写入 stdout
;要保存输出到文件,请使用管道(例如,ressenter comments > comments.jsonl
)。
评论
Usage: ressenter comments [OPTIONS]
Pull all the most recent comments
Options:
--sort [latest|controversial|top]
comment sort order
--after-id TEXT pull no earlier than this comment ID
--after-time TEXT pull no comments posted earlier than this
time
--max INTEGER maximum number of comments to pull
--help Show this message and exit.
趋势
Usage: ressenter trending [OPTIONS]
Pull the current trending URLs
Options:
--help Show this message and exit.
URL
Usage: ressenter url [OPTIONS] URL
Pull comments for a particular URL. Note that several comment metadata
items (such as upvotes, downvotes, and comments) are not available when
pulling comments from a URL.
Options:
--sort [latest|controversial|top]
comment sort order
--after-id TEXT pull no earlier than this comment ID
--after-time TEXT pull no comments posted earlier than this
time
--max INTEGER maximum number of comments to pull
--help Show this message and exit.
用户
Usage: ressenter user [OPTIONS] USER
Pull all the comments of a particular user, identified by their UID
Options:
--sort [latest|controversial|top]
comment sort order
--after-id TEXT pull no earlier than this comment ID
--after-time TEXT pull no comments posted earlier than this
time
--max INTEGER maximum number of comments to pull
--help Show this message and exit.
操作手册
以下是一些常见用例
获取所有最新的评论
ressenter comments
获取所有最近的热门评论
ressenter comments --sort=top
获取所有最近的争议性评论
ressenter comments --sort=controversial
获取过去一小时内的所有评论
ressenter comments --after-time "one hour ago"
获取所有当前趋势的 URL
ressenter trending
获取特定 URL 的所有评论
ressenter url https://#
模块使用
要将 Ressenter 作为 Python 模块使用,只需导入它并设置一个监听器——一个在每次结果上被调用的函数。您还可能想禁用标准输出。例如
import ressenter
results = []
ressenter.disable_standard_output()
ressenter.result_listeners.append(results.append)
ressenter.result_listeners.append(lambda k: print(f"Output: {k}"))
ressenter.comments()
print(f"Found {len(results)} results!")
所有命令都导入到顶层命名空间(例如,ressenter.comments
、ressenter.trending
、ressenter.url
、ressenter.user
)并且支持与它们的命令行等效物相同的参数。有关特定参数的更多信息,请参阅源代码和命令级别文档。
开发
要在本地运行 Ressenter,请执行以下步骤
- 使用
pipenv install
安装依赖项 - 使用
pipenv shell
激活虚拟环境 - 使用
main.py
运行工具——例如,./main.py comments
打包和发布
- 请确保您有权访问 PyPI 凭证,并具有访问
ressenter
存储库的权限。 - 清空
dist/
文件夹(rm dist/*
)。 - 使用
python setup.py sdist bdist_wheel
打包所有内容。 - 使用
twine check dist/*
检查打包。 - 使用
twine upload dist/*
上传。
故障排除
如果您在斯坦福互联网观察站工作,请通过 Slack 或电子邮件 ping Miles McCain 获取 Ressenter 的帮助。要报告错误或提交功能请求,请打开问题。
所需功能
此工具目前缺少一些功能,但我们希望添加。我们尚未找到提取这些数据的可靠方法。(如果您找到了,请告诉我们!)
- 找到最近评论过的所有 URL
- 遍历所有带有评论的 URL
- 遍历所有评论,而不仅仅是过去七天内的评论
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。