Skip to main content

A professional Weibo crawler library

Project description

Crawl4Weibo

一个开箱即用的微博爬虫Python库,基于实际测试成功的方案,无需Cookie即可使用。

特性

  • 🚀 开箱即用: 无需Cookie,一行代码初始化
  • 🛡️ 防反爬: 自动处理432错误和请求限制
  • 📱 真实模拟: 使用真实手机浏览器UA
  • 🔄 智能重试: 自动重试机制
  • 📊 结构化数据: 清晰的数据模型

安装

pip install crawl4weibo

快速开始

from crawl4weibo import WeiboClient

# 初始化(无需Cookie)
client = WeiboClient()

# 获取用户信息
user = client.get_user_by_uid("1195230310")
print(f"用户: {user.screen_name}")
print(f"粉丝: {user.followers_count:,}")

# 获取微博
posts = client.get_user_posts("1195230310")
for post in posts:
    print(f"微博: {post.text[:50]}...")
    print(f"点赞: {post.attitudes_count}")

# 搜索用户
users = client.search_users("技术博主")
for user in users:
    print(f"用户: {user.screen_name}")

# 搜索微博  
posts = client.search_posts("人工智能")
for post in posts:
    print(f"内容: {post.text[:50]}...")

API参考

WeiboClient

初始化

WeiboClient(cookies=None, log_level="INFO", log_file=None)

主要方法

  • get_user_by_uid(uid) - 获取用户信息
  • get_user_posts(uid, page=1) - 获取用户微博
  • search_users(query, page=1, count=10) - 搜索用户
  • search_posts(query, page=1) - 搜索微博

运行示例

python examples/simple_example.py

技术实现

基于你提供的成功代码实现:

# 核心技术栈
- Android Chrome UA模拟
- 移动端API接口
- 自动session管理  
- 432错误智能重试
- 随机请求间隔

许可证

MIT License

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

crawl4weibo-0.1.1.tar.gz (99.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crawl4weibo-0.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file crawl4weibo-0.1.1.tar.gz.

File metadata

  • Download URL: crawl4weibo-0.1.1.tar.gz
  • Upload date:
  • Size: 99.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for crawl4weibo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bfbe1369c7003e13fa3034d27bc762c027c889fb68f60cfe6d68297b9cc742b1
MD5 49067a30f167a6844c67c5cbd77ad7a1
BLAKE2b-256 715493c9c1d31828d650bbb2d4baad241f85bbf5a47acab15fe4b51665e1252c

See more details on using hashes here.

File details

Details for the file crawl4weibo-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for crawl4weibo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b3ac1db277bf5d97239118df10f7f45f3fd621bcffec104ee6f70e2ad37afc6c
MD5 e5370bb9feb2fc73a5d2f9f99810be22
BLAKE2b-256 1f27b3b627a274dcc08317bba9291e7882b7f62ac89eb740288cf08b577172a5

See more details on using hashes here.

Supported by

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