picture-lake-weibo: 使用新浪微博做图床
對於經常要文檔的碼農來說,沒有一個好的圖床真的非常麻煩。對比之下,把新浪微博作爲圖床在訪問效率上是最高的。
於是晚上就自己擼一個吧。
安裝
本工具目前僅支持Python3,Python2的需要修改一下代碼,比如用six做一些封裝。
pip3 install picture-lake-weibo
使用
$ picture-lake-weibo --help
usage: picture-lake-weibo {login,upload} [pictures [pictures ...]]
登錄新浪微博
首先我們需要登錄新浪微博
picture-lake-weibo login
在輸入用戶名和密碼後,會提示登錄成功。
此登錄邏輯,參考Python3 模拟登录新浪微博
上傳圖片
picture-lake-weibo upload XXX.jpg
如果上傳成功,會得到類似如下信息:
上傳成功 => /Users/wuliang/Pictures/DCIM/Camera/20190130_184343.jpg, https://tva1.sinaimg.cn/large/703708dcly1g5v0w46x48j20u01hc1ky
多圖片上傳
可以指定多個文件或者通配符來同時上傳多個圖片
picture-lake-weibo upload a.jpg b.jpg
picture-lake-weibo upload *.jpg
相對路徑和絕對路徑都支持
picture-lake-weibo upload ../../test.jpg
picture-lake-weibo upload /home/admin/test.jpg
替換Markdown文件中的圖片
picture-lake-weibo replace XXX.md
配置
默認的配置在$HOME/.picture-lake-weibo.json下,類似如此:
{
"hostname": "tva1.sinaimg.cn",
"protocol": "https",
"size": "large",
"username": "15912345678",
"password": "1234567"
}
因此除了登陸新浪微博的用戶名和密碼外,我們還可以對圖片的域名、協議、尺寸做配置。
協議(protocol)
協議支持兩種:
- http
- https
域名(hostname)
域名支持:
- tva1.sinaimg.cn
- tvax1.sinaimg.cn
- ww1.sinaimg.cn
- ws1.sinaimg.cn
- wx1.sinaimg.cn
尺寸
尺寸支持:
- large(原圖)
- mw690(690高)
- bmiddle(中图)
- small(小图)
- mw2048(超大)
- mw1024(超大)
- orj480
- orj480
- thumb150(缩略图)
- square
代理
可以在$HOME/.picture-lake-weibo.json中增加proxy選項,以支持代理服務器
{
"proxy": "http://127.0.0.1:8888"
}
socks5也一樣:
{
"proxy": "sock5://127.0.0.1:1080"
}
Metadata
Release files for picture-lake-weibo 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| picture-lake-weibo-0.0.5.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| picture_lake_weibo-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.2 kB
Release files / picture-lake-weibo-0.0.5.tar.gz
| Download URL | picture-lake-weibo-0.0.5.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
786cd06b7247d5a907501cc10eec9fc27b4a77451da3bca4c12d8028dd446ec6
|
|
BLAKE2b-256 checksum How to use checksums |
6b143fc6d447ba0548ca59212de3542696b21ccc035a65ce3f1c8417fd8cee4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
|
Release files / picture_lake_weibo-0.0.5-py3-none-any.whl
| Download URL | picture_lake_weibo-0.0.5-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e38640e526c10988201c3527bb07fba868e15a5d7f284d6ccc3569aa695480cb
|
|
BLAKE2b-256 checksum How to use checksums |
8d76b3efb8e6be14d021287feeb64e822bc0afef6f19c9943b3c4ed08f9cc4fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
|