Skip to main content

PyWeibo

Version Download License Status

Python SDK for Weibo API.

中文文档

Installation

pip install pyweibo

Preparation

  1. Register the Sina Weibo account, and establish a new app in open.weibo.com.

  2. Get App Key and App Secret from 应用信息 -> 基本信息

  3. Set Redirect URI in 应用信息 -> 高级信息 -> OAuth2.0授权设置 as:

https://api.weibo.com/oauth2/default.html

Usage

Authentication

Basic usage

from pyweibo import Auth
auth = Auth()

When running, you need to manually input App Key and App Token:

App Key: <Your App Key>
App Secret: <Your App Secret>

Next the web browser will automatically open the redirect uri.

Copy the uri to the console, and the token will be generated:

Input the url or the token: <The URL or token>

Finally, the token will also be stored in ./token.json.

As for advanced usages, you can specify:

API Client

Basic usage

from pyweibo import Auth, Client

# Get the token
auth = Auth()
token = auth.token.token

# Start the client
client = Client()
data = client.statuses.home_timeline.get(access_token=token)
  • The APIs and their parameters can be referred from official docs.

  • You can access the api call like class attributes, where the last method call must be get or post.

client.api_name_1.api_name_2.get(param1=value1, param2=value2)
  • Also you can use dict index like:
client[api_name_1][api_name_2].get(param1=value1, param2=value2)
  • The return value is a TextDict, where you can access the attributes directly like:
user = data.statuses[0].user
  • Also you can upload the picture with the parameter pic:
with open('image.png', 'rb') as f:
    client.statuses.upload_pic.post(pic=f)
from pyweibo import UploadClient

client = UploadClient()
with open('image.png', 'rb') as f:
    client.statuses.upload.post(status='Image', pic=f)

Contribute

Project:Thesharing/pyweibo

Establish new issue if there is any question or advice.

Reference

michaelliao/sinaweibopy

lxyu/weibo

Thesharing/spider-util

Metadata

Release files for pyweibo 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyweibo 0.1.2
File Size Uploaded
pyweibo-0.1.2.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyweibo 0.1.2
File Interpreter ABI Platform
pyweibo-0.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 11.3 kB

Release files / pyweibo-0.1.2.tar.gz

Download URL pyweibo-0.1.2.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1728dbb71ec76839471e560c8711aa91d6ac3dfc807bbe31003610ee267aff91
BLAKE2b-256 checksum
How to use checksums
8d77dae01e581fcd716c0f67a61b690358e988b163192a65a1e12186dad992d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / pyweibo-0.1.2-py2.py3-none-any.whl

Download URL pyweibo-0.1.2-py2.py3-none-any.whl
Size 6.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c42ed46cc946a84b7aff8bcf3581364c57d632ab3fbe55e43a8b1e6ee6d5e77a
BLAKE2b-256 checksum
How to use checksums
fa7cec5aa4c7e0ec7761f6270643856f1f5bb3a3175bbb1b9a4534828ec04a3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page