如何获取你所有的书签推文并使它们可以通过网络界面访问(附代码)

473 阅读2分钟

TBM - Twitter书签管理器

Fetch all your bookmarked tweets and make them accessible through a webinterface

取出你所有的书签推文,并使它们可以通过网络界面访问。

Fetch all your bookmarked tweets and make them accessible through a webinterface Fetch all your bookmarked tweets and make them accessible through a webinterface Fetch all your bookmarked tweets and make them accessible through a webinterface Fetch all your bookmarked tweets and make them accessible through a webinterface

功能介绍

  • 取出所有被收藏的推文
  • 搜索所有包含给定短语的书签推文(这包括:用户名、真实姓名、标签、推文内容和真实尿液)。

使用方法

为了获取你的书签,你必须提供一个有效的访问令牌和一个匹配的cookie。 你可以通过以下步骤获得这两点。

  1. 登录twitter.com并进入twitter.com/i/bookmarks
  2. f12 ,切换到Network 标签,寻找一个名为 "请求 "的请求。Bookmarks?variables=%7B%22count%22%3A20..
  3. 切换到Headers 标签,如果它没有被选中,向下滚动到Request Headers
  4. 复制以cookie: 开始的一行,然后authorization: Bearer
  5. 检查section 是否有变化(Bookmarks?variables=%7B%22count%22%3A20.. 前面的部分网址),如果有,也复制它。
Usage of tbm:
  -access-token string
        Twitter bearer access token
  -config string
        Application config file (default "./config/config.json")
  -cookie string
        Twitter cookie string
  -data-dir string
        Folder containing all fetched data (default "./data")
  -host string
        Host address the api should bind to (default "localhost")
  -port uint
        Port the api should bind to (default 4788)
  -section string
        Twitter bookmark api section name (default "BvX-1Exs_MDBeKAedv2T_w")
  -timezone string
        Application time zone (default "UTC")
  -version
        Show version and exit

配置

除了命令参数,你还可以提供一个配置文件:

{
  "timezone": "UTC",
  "data_dir": "./data",
  "server": {
    "host": "localhost",
    "port": 4788
  },
  "scraper": {
    "section": "BvX-1Exs_MDBeKAedv2T_w",
    "cookie": "guest_id=...",
    "access_token": "AAAAA..."
  }
}
  

Websocket命令

可以在ws://{host}:{port}/ws 下访问websocket。

设置访问令牌和cookie:

{
  "command":"set_tokens",
  "payload":{
    "cookie": "guest_id=...",
    "access_token": "AAAAA..."
  }
}
  

获取所有推文:

{
  "command":"get_tweets",
  "payload":{}
}
  

搜索包含搜索查询的推文:

{
  "command":"search_tweets",
  "payload":{
    "query": "foo bar"
  }
}
  

自定义样式

默认情况下,所有资产(.js、.css、.html等)在构建新版本时都会被包含在内。

结构

  • 圭臬
    • css
      • tailwind.css
  • 公共
    • css
      • tailwind.css(已编译的tailwind css)
      • style.css (自定义样式)
    • js
      • app.js
    • index.html

开发

要求:

  • Node v12.13
  • Golang ^1.17.2
npm run watch
npm run build
go run main.go

构建

构建一个新的版本:

./build.sh

构建一个新的常规二进制文件:

go build -ldflags "-w -s -X main.buildNumber=1 -X main.buildVersion=custom" -o tbm

功能和拉动请求

每个人都可以为这个项目做出贡献。每个拉动请求都会被考虑,但也有可能被拒绝。 为了避免不必要的工作,如果你打算做较大的改动,请考虑先创建一个特性问题。当然,如果你只是希望得到一个功能,你也可以创建一个新的功能问题😉。

偏离主题、无礼或辱骂的问题将被删除,不作任何通知。