没有项目描述

weibo-scraper的Python项目详细描述


微博刮板

PyPIPyPI - Python VersionBuild Statuscodecov


简单的微博刮板。擅自抓取微博。 官方api有很多限制。 一般来说,我们可以通过chrome来检查有自己api的移动站点。


为什么

  1. 抓取微博数据以研究大数据。

  2. 备份微博可耻封锁的数据。


安装

PIP

$ pip install weibo-scraper

或者升级它。

$ pip install --upgrade weibo-scraper

pipenv

$ pipenv install weibo-scraper

或者升级它。

$ pipenv update --outdated # show packages which are outdated

$ pipenv update weibo-scraper # just update weibo-scraper

仅支持Python 3.6+。


用法

  1. 首先,你可以通过nameuid获得微博简介。
>>>fromweibo_scraperimportget_weibo_profile>>>weibo_profile=get_weibo_profile(name='来去之间',)>>>....

您将得到类型为weibo_base.UserMeta的微博配置文件响应,该响应包括以下字段

fieldchinesetypesampleext
id用户idstr
screen_name微博昵称Option[str]
avatar_hd高清头像Option[str]'https://ww2.sinaimg.cn/orj480/4242e8adjw8elz58g3kyvj20c80c8myg.jpg'
cover_image_phone手机版封面Option[str]'https://tva1.sinaimg.cn/crop.0.0.640.640.640/549d0121tw1egm1kjly3jj20hs0hsq4f.jpg'
description描述Option[str]
follow_count关注数Option[int]3568
follower_count被关注数Option[int]794803
gender性别Option[str]'m'/'f'
raw_user_response原始返回Option[dict]
  1. 其次,通过tweet_container_id获取微博是一种罕见的使用方式,但它也很有效。
>>>fromweibo_scraperimportget_weibo_tweets>>>fortweetinget_weibo_tweets(tweet_container_id='1076033637346297',pages=1):>>>print(tweet)>>>....
    当然,你也可以通过现有的昵称获得原始微博微博。而pages的参数是可选的。
>>>fromweibo_scraperimportget_weibo_tweets_by_name>>>fortweetinget_weibo_tweets_by_name(name='嘻红豆',pages=1):>>>print(tweet)>>>....
  1. 如果要获取所有tweets,可以将pages的参数设置为None
>>>fromweibo_scraperimportget_weibo_tweets_by_name>>>fortweetinget_weibo_tweets_by_name(name='嘻红豆',pages=None):>>>print(tweet)>>>....
  1. 从1.0.5开始有一个巨大的更新!

您还可以通过weibo_scrapy.get_formatted_weibo_tweets_by_name

的api获取格式化的tweets
>>>fromweibo_scraperimportget_formatted_weibo_tweets_by_name>>>result_iterator=get_formatted_weibo_tweets_by_name(name='嘻红豆',pages=None)>>>foruser_metainresult_iterator:>>>fortweetMetainuser_meta.cards_node:>>>print(tweetMeta.mblog.text)>>>....

img


微博粉丝

Weibo Flasgger是一个用于weibo scraper的web api文档,由flasger提供支持。

img

P.S

  1. 灵感来自Twitter-Scraper

  2. 为了“西红豆”。

  3. 欢迎用叉子叉我。


许可证

麻省理工学院

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java如何添加排除某个数字的随机生成器?   在Eclipse中将所有包集中在一个包中(对于Java项目)   java在部署我的应用程序后无法连接到MySQL   Ntier应用程序中的java NoClassDefFoundException   java泛型类型转换?   使用buildr编译期间的java jar插件   java查找排序数组中重复值的计数   运行Spring Boot cmdline的java示例给出了“找不到run()方法”`   java为什么不调用windowClosed?   java jsch身份验证在没有私钥的情况下失败   java如何在我的jtable中获得100多行?   java在遗留Android Studio项目中创建测试文件夹   java 安卓。所容纳之物res.Resources$NotFoundException:资源ID#0x7f080087   java Eclipse自动格式化变量初始化