没有项目描述
weibo-scraper的Python项目详细描述
微博刮板
简单的微博刮板。擅自抓取微博。 官方api有很多限制。 一般来说,我们可以通过chrome来检查有自己api的移动站点。
为什么
抓取微博数据以研究大数据。
备份微博可耻封锁的数据。
安装
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+。
用法
- 首先,你可以通过
name
或uid
获得微博简介。
>>>fromweibo_scraperimportget_weibo_profile>>>weibo_profile=get_weibo_profile(name='来去之间',)>>>....
您将得到类型为weibo_base.UserMeta
的微博配置文件响应,该响应包括以下字段
field | chinese | type | sample | ext |
---|---|---|---|---|
id | 用户id | str | ||
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] |
- 其次,通过
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)>>>....
- 如果要获取所有tweets,可以将
pages
的参数设置为None
>>>fromweibo_scraperimportget_weibo_tweets_by_name>>>fortweetinget_weibo_tweets_by_name(name='嘻红豆',pages=None):>>>print(tweet)>>>....
- 从1.0.5开始有一个巨大的更新!
您还可以通过weibo_scrapy.get_formatted_weibo_tweets_by_name
,
>>>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)>>>....
微博粉丝
Weibo Flasgger是一个用于weibo scraper的web api文档,由flasger提供支持。
P.S灵感来自Twitter-Scraper。
为了“西红豆”。
欢迎用叉子叉我。
许可证
灵感来自Twitter-Scraper。
为了“西红豆”。
欢迎用叉子叉我。
麻省理工学院