Weibo trending posts scraper
Project description
Weibo trending posts scraper
Scrap trending posts from Weibo front page.
Usage guide
As a library
Install
pip install weibo-trending
Get and parse posts
from weibo_trending import get_new_posts, parse_response
resp = get_new_posts()
mblogs = parse_response(resp)
for mblog in mblogs:
print(mblog)
Get and parse comments
from weibo_trending import get_raw_comments, parse_comments
example_post_id = "4840673008419178"
raw_cmt = get_raw_comments(example_post_id)
comments = parse_comments(raw_cmt)
for c in comments:
print(c)
As a command line tool
Install
pip install weibo-trending
Usage
python -m weibo_trending --help
usage: weibo_trending [-h] [-d DIR] [-s]
Scrape and parse Weibo trending posts.
optional arguments:
-h, --help show this help message and exit
-d DIR, --dir DIR specify the output directory. Defaults to the current working directory
-s, --skip-parsing whether to skip parsing and dump the raw JSON response from Weibo
python -m weibo_trending
weibo_trending will save each scraped post with the following filename format:
weibo_<user ID>_<post ID>.json
- Example:
weibo_1631153043_4834313265233660.json
Each call to weibo_trending usually saves 10 new files. If you get fewer than 10, that means the response contains one or more deleted posts. They are not saved.
Develop
git clone https://github.com/ericlingit/weibo-trending.git
cd weibo-trending
python3 -m venv venv
source venv/bin/activate
pip install -U pip wheel
pip install -r requirements.txt
pip install -e .
pytest
Package
python -m build --wheel
The built wheel is in ./dist/
.
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
weibo_trending-0.0.6.tar.gz
(49.8 kB
view details)
Built Distribution
File details
Details for the file weibo_trending-0.0.6.tar.gz
.
File metadata
- Download URL: weibo_trending-0.0.6.tar.gz
- Upload date:
- Size: 49.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d932b5500e15a71112d9fe14f132a2ee9c5e713a14f93ab29852f080d7f560ba |
|
MD5 | 63070106e4a44b8cd20a81c2bd0ef8eb |
|
BLAKE2b-256 | d7e91234cb9323b269a12be5ce3cede55dc439a234179748a128a2d78958f877 |
File details
Details for the file weibo_trending-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: weibo_trending-0.0.6-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c825e9fad350bbfb0997917a31b4e45ce67c0870aa4da103f3ec29dddb16603 |
|
MD5 | 280f00c6e096e91031a1f1c90129207d |
|
BLAKE2b-256 | 6179fede382b71eb10a9e971f79e16dfb34f7fb9b95318ae633318699aa1afa9 |