新浪微博简易爬虫,读取特定用户原创微博
目前github上排名靠前的几个爬虫都是爬取页面的,有个局限是需要授权,不然会跳到登录页面,非常不友好。
F12后发现微博的ajax接口是没有什么限制的,而且直接返回json,不用处理页面。
- python3
- requests
pip install requests或者用pipenv
pip install pipenv
pipenv install
pipenv shellpython weibo_read.py <uid>比如打印深圳天气的微博
python weibo_read.py 1871802012如果一定要用python2来执行,可以在前面添加:
reload(sys)
sys.setdefaultencoding('utf-8')