Skip to main content

把新浪微博作爲圖床

Project description

picture-lake-weibo: 使用新浪微博做图床

對於經常要文檔的碼農來說,沒有一個好的圖床真的非常麻煩。對比之下,把新浪微博作爲圖床在訪問效率上是最高的。

於是晚上就自己擼一個吧。

4444.gif

安裝

本工具目前僅支持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"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

picture-lake-weibo-0.0.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

picture_lake_weibo-0.0.5-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file picture-lake-weibo-0.0.5.tar.gz.

File metadata

  • Download URL: picture-lake-weibo-0.0.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for picture-lake-weibo-0.0.5.tar.gz
Algorithm Hash digest
SHA256 786cd06b7247d5a907501cc10eec9fc27b4a77451da3bca4c12d8028dd446ec6
MD5 3df75624b8d7b600879c1035dc656e2c
BLAKE2b-256 6b143fc6d447ba0548ca59212de3542696b21ccc035a65ce3f1c8417fd8cee4a

See more details on using hashes here.

File details

Details for the file picture_lake_weibo-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: picture_lake_weibo-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for picture_lake_weibo-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e38640e526c10988201c3527bb07fba868e15a5d7f284d6ccc3569aa695480cb
MD5 0252a0541679802a9cbc343b89b8db96
BLAKE2b-256 8d76b3efb8e6be14d021287feeb64e822bc0afef6f19c9943b3c4ed08f9cc4fc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page