跳转到主要内容

GETTR的提取工具,一个“无偏见”的社会网络。

项目描述

GoGettr

GoGettr是GETTR(一个“无偏见”的社会网络)的API客户端。GoGettr由斯坦福互联网观察站构建和维护。

此工具目前不需要与GETTR进行任何身份验证;它通过公开可访问的端点收集所有数据。

目前,此工具可以

  • 拉取平台上的帖子
  • 拉取平台上的评论
  • 拉取所有顶级“趋势”标签
  • 拉取所有推荐用户
  • 拉取所有“趋势”帖子(即主页上的帖子)
  • 拉取平台上某个用户的全部帖子或评论
  • 拉取某个用户的全部关注者
  • 拉取某个用户关注的全部用户
  • 拉取特定帖子的全部评论
  • 拉取特定用户的个人资料信息

GoGettr设计用于学术研究、开源情报收集和数据归档。它从公开可访问的API中拉取所有数据。

安装

GoGettr 已在 PyPI 上提供。要安装它,只需运行 pip install gogettr。只要你的 pip 设置正确,这将会使 gogettr 既可以作为命令,也可以作为 Python 包使用。请注意,GoGettr 需要 Python 3.8 或更高版本。

CLI 指南

获取所有帖子(从 id 1 开始,最多 1m)

gogettr all --max 1000000

获取所有评论

gogettr all --type comments --max 1000000

获取所有帖子(从特定 ID 开始,向后移动到 IDs)

gogettr all --rev --last pay8d

获取某个用户的全部帖子

gogettr user USERNAME --type posts

获取某个用户的全部评论

gogettr user USERNAME --type comments

获取某个用户的全部点赞

gogettr user USERNAME --type likes

获取用户的个人信息

gogettr user-info USERNAME

CLI 使用方法

Usage: gogettr [OPTIONS] COMMAND [ARGS]...

  GoGettr is an unauthenticated API client for GETTR.

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  all             Pull all posts (or comments) sequentially.
  comments        Pull comments on a specific post.
  hashtags        Pull the suggested hashtags (the top suggestions are...
  live            Pull livestream posts.
  search          Search posts for the given query.
  suggested       Pull the suggested users (users displayed on the home...
  trends          Pull all the trends (posts displayed on the home page).
  user            Pull the posts, likes, or comments made by a user.
  user-followers  Pull all a user's followers.
  user-following  Pull all users a given user follows.
  user-info       Pull given user's information.

all

Usage: gogettr all [OPTIONS]

  Pull all posts (or comments) sequentially.

  Note that if iterating chronologically and both max and last are unset, then
  this command will run forever (as it will iterate through all post IDs to
  infinity). To prevent this, either specify a max, last post, or iterate
  reverse chronologically.

  Posts will be pulled in parallel according to the desired number of workers.
  Out of respect for GETTR's servers, avoid setting the number of workers to
  values over 50.

Options:
  --first TEXT             the ID of the first post to pull
  --last TEXT              the ID of the last post to pull
  --max INTEGER            the maximum number of posts to pull
  --rev                    increment reverse chronologically (i.e., from last
                           to first)
  --type [posts|comments]
  --workers INTEGER        the number of threads to run in parallel
  --help                   Show this message and exit.

comments

Usage: gogettr comments [OPTIONS] POST_ID

  Pull comments on a specific post.

Options:
  --max INTEGER  the maximum number of comments to pull
  --help         Show this message and exit.

hashtags

Usage: gogettr hashtags [OPTIONS]

  Pull the suggested hashtags (the top suggestions are displayed on the front
  page).

  Note that while the first five or so hashtags have expanded information
  associated with them, later results do not.

Options:
  --max INTEGER  the maximum number of hashtags to pull
  --help         Show this message and exit.

search

Usage: gogettr search [OPTIONS] QUERY

  Search posts for the given query.

  This is equivalent to putting the query in the GETTR search box and
  archiving all the posts that result.

Options:
  --max INTEGER  the maximum number of posts to pull
  --help         Show this message and exit

suggested

Usage: gogettr suggested [OPTIONS]

  Pull the suggested users (users displayed on the home page).

Options:
  --max INTEGER  the maximum number of users to pull
  --help         Show this message and exit.

trends

Usage: gogettr trends [OPTIONS]

  Pull all the trends (posts displayed on the home page).

Options:
  --max INTEGER  the maximum number of posts to pull
  --until TEXT   the ID of the earliest post to pull
  --help         Show this message and exit.

user

Usage: gogettr user [OPTIONS] USERNAME

  Pull the posts, likes, or comments made by a user.

Options:
  --max INTEGER                  the maximum number of activities to pull
  --until TEXT                   the ID of the earliest activity to pull for
                                 the user
  --type [posts|comments|likes]
  --help                         Show this message and exit.

user-followers

Usage: gogettr user-followers [OPTIONS] USERNAME

  Pull all a user's followers.

Options:
  --max INTEGER  the maximum number of users to pull
  --help         Show this message and exit.

user-following

Usage: gogettr user-following [OPTIONS] USERNAME

  Pull all users a given user follows.

Options:
  --max INTEGER  the maximum number of users to pull
  --help         Show this message and exit.

user-info

Usage: gogettr user-info [OPTIONS] USERNAME

  Pull given user's information.

Options:
  --help  Show this message and exit.

live

Usage: gogettr live [OPTIONS]

  Pull livestream posts.

Options:
  --max INTEGER  the maximum number of livestream entries to pull
  --help         Show this message and exit.

模块使用

您可以将 GoGettr 作为 Python 模块使用。例如,以下是如何获取某个用户的所有帖子的方法:

from gogettr import PublicClient
client = PublicClient()
posts = client.user_activity(username="support", type="posts")

有关如何将 GoGettr 作为模块使用的更多示例,请参阅 测试目录。请注意,API 表面还不能被认为是非常稳定的。如果 Gettr 更改他们的 API,GoGettr 的 API 可能会相应更改(尽管会尽量减少对公共 API 的更改)。

GoGettr 将相关的 API 功能组合到同一功能中;例如,获取用户的评论、帖子和点赞都是通过同一个函数(在 user_activity.py 内部)完成的,获取关注者和被关注者是通过同一个函数(在 user_relationships.py 内部)完成的。这意味着 CLI 表面和 API 表面之间并不完全对应。

开发

要在开发环境中运行 gogettr,您需要 Poetry。通过运行 poetry install 安装依赖项,然后您就可以在本地工作在 gogettr 上。

要运行测试,请运行 poetry run pytest

要访问 CLI,请运行 poetry run gogettr

要打包并发布新版本到 PyPI,只需在 GitHub 上创建一个新的发布标签。

贡献

欢迎贡献!对于小的错误修复和小的改进,您可以随意提交 PR。对于更大的更改,请首先打开一个问题,以便其他贡献者可以讨论您的计划,避免重复工作,并确保它与项目的目标一致。请确保还遵循 行为准则。谢谢!

日志记录

在 CLI 模式下运行时,GoGettr 将将详细的调试信息记录到 gogettr.log(在工作目录中)。此日志将包括 GoGettr 所做的每个请求和接收到的每个响应。由于 GoGettr 在解析 API 响应时可能会意外丢失一些信息,因此请考虑保留此文件以备不时之需。

愿望清单

计划支持以下功能

  • ...目前没有!(有什么想法吗?提交问题/PR!)

项目详情


下载文件

为您的平台下载文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分发

gogettr-0.9.0.tar.gz (17.4 kB 查看散列)

上传时间

构建分发

gogettr-0.9.0-py3-none-any.whl (22.8 kB 查看哈希值)

上传时间: Python 3

支持