Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/easoncxz/weibo-export
Save your posts from weibo.com, despite weibo's hostile API
https://github.com/easoncxz/weibo-export
weibo weibo-export
Last synced: 13 days ago
JSON representation
Save your posts from weibo.com, despite weibo's hostile API
- Host: GitHub
- URL: https://github.com/easoncxz/weibo-export
- Owner: easoncxz
- License: bsd-3-clause
- Created: 2018-03-18T11:23:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-17T13:23:34.000Z (over 4 years ago)
- Last Synced: 2024-10-25T06:50:42.522Z (2 months ago)
- Topics: weibo, weibo-export
- Language: Haskell
- Size: 139 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
weibo-export
============[![Build Status](https://travis-ci.org/easoncxz/weibo-export.svg?branch=master)](https://travis-ci.org/easoncxz/weibo-export)
A CLI tool to help you download posts from your own [weibo.com][weibo] account.
一个帮助你下载你自己的微博的命令行工具。
Since most people interested in this are expected to be Chinese-language
speakers, the rest of this document is written in Chinese only. The
command-line help docs via `weibo-export --help` is in English and English
only.# 用途
这是我主要写给自己用的。我希望能尽可能多地下载保留自己微博帐号上的信息, 以对可能的炸号做准备。
# 工作原理
这个程序是在模仿 m.weibo.cn 手机网页版客户端从浏览器里发的请求,以从同一个服务器 API 处获得微博内容。因此,但凡 m.weibo.cn 有改版更新,本程序都会失效,需要更新后方可使用。
# 安装
### Mac OS
欢迎通过 [Homebrew][brew] 安装:
brew install easoncxz/tap/weibo-export
或者可以遵以下 Linux 用户的指示,从源代码编译。
### Linux
抱歉,我尚未研究好如何自动发布预编译版本给 Linux 用户。烦请安装 Haskell 的 build tool 自行编译:
git clone [email protected]:easoncxz/weibo-export.git
cd weibo-export
./automation/install-stack.sh
stack build
stack exec weibo-export -- --help可以安装到用户全局使用:
stack install
以上命令将会放置一个可执行文件到 `~/.local/bin`. 如果你喜欢,可以将这个目录加到你的 `PATH` 环境变量中以方便使用 `weibo-export`.
# 使用
weibo-export: 0.2.0.0
Usage: weibo-export ((-v|--version) | (-u|--user ARG) [-p|--start-from-page ARG]
(-o|--output-dir ARG) [-w|--no-wait])
Download Weibo statuses via the m.weibo.cn mobile web APIAvailable options:
-v,--version Display the version of weibo-export
-u,--user ARG User ID on weibo, e.g. "3563717322"
-p,--start-from-page ARG Start downloading from this page (default: 1)
-o,--output-dir ARG Where to put downloaded files. This will be created
with `mkdir -p` if it doesn't exist.
-w,--no-wait Don't wait, be aggressive, and risk being
rate-limited
-h,--help Show this help text请上微博找到你的用户 ID. 这是一串大概 10 位长的数字。比如,`1537790411` 好象是一个叫「鹿晗」的人的 user ID. 一般 user ID 会出现在浏览器地址栏里,比如:
https://m.weibo.cn/u/1537790411
复制了你的用户 ID 之后,可以开始使用本工具。
weibo-export \
-o weibo-downloaded \
-u 1537790411我个人喜欢用 `tee` 命令在观看输出的同时,记录一份日志,好知道我下载了多少、下载了哪些微博。
weibo-export \
-o weibo-downloaded \
-u 1537790411 | tee -a weibo-export.log终端内的日志信息样例:(`0000000000000000` 是我手动打的码)
Starting download for page 198 of statuses...
Saved page 198 of statuses
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Starting download for page 199 of statuses...
Saved page 199 of statuses
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json
Saved Status to: weibo-downloaded/status-normal-0000000000000000.json可以随时用 Ctrl-C 来中断下载;已下载的文件不会丢失。也可以任意地重新下载;相应的输出文件会被覆盖。
输出文件格式是新浪服务器 API 的一部分,暂时每条微博一个 JSON 文件来储存。
可以用 [`jq`][jq] 进行检阅、分析,和处理。# 构思中的新功能
说不准我什么时候写,但是我目前先到的有:
- 扩大下载范畴:
- 评论
- 自己微博的图片
- 转发的微博其正文
- 转发的微博的图片
- 想办法对设置了隐私微博号的用户提供一些支持
- 改善储存格式:或许存为 sqlite?
- 改善读取方式:提供建议 web UI / HTML 输出?# 版权协议
BSD 3-clause 协议。详见 [LICENSE](./LICENSE)。
[weibo]: http://weibo.com
[brew]: https://brew.sh/
[jq]: https://stedolan.github.io/jq/