Python爬虫:微博粉丝列表
前言
本来打算做一个关于微博粉丝列表的爬虫,可以统计一下某个微博账号的粉丝里面,僵尸粉(水军)的数量,大V数量。
结果写完爬虫才发现,现在微博只给人看粉丝列表的前5页.......哈哈,好吧。挺无奈的,淘宝那边也是只展示前100页的评论。
爬虫代码
直接上爬虫代码
import requests
import re tmpt_url = 'https://weibo.com/p/1005051678105910/follow?page=%d#Pl_Official_HisRelation__59'
def get_data(tmpt_url):
urllist = [tmpt_url%i for i in range(1,6)]
user_id = [] #粉丝ID
user_name = [] #粉丝名称
user_follow = [] #粉丝的关注
user_fans = [] #粉丝的粉丝量
user_address = [] #粉丝的地址 headers = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding':'gzip, deflate, br',
'Accept-Language':'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'Connection':'keep-alive',
'Cookie':'请在自己的浏览器中查看,因涉及个人隐私不公开',
'Host':'weibo.com',
'Upgrade-Insecure-Requests':'',
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0'} for url in urllist:
html = requests.get(url,headers=headers).text
user_id.extend(re.findall(r'<a class=\\"S_txt1\\" target=\\"_blank\\" usercard=\\"id=(\d+)&refer_flag=\d+_\\" href=\\"\\/\S+\?refer_flag=\d+_\\" >\S+<\\/a>',html))
user_name.extend(re.findall(r'<a class=\\"S_txt1\\" target=\\"_blank\\" usercard=\\"id=\d+&refer_flag=\d+_\\" href=\\"\\/\S+\?refer_flag=\d+_\\" >(\S+)<\\/a>',html))
user_follow.extend(re.findall(r'关注 <em class=\\"count\\"><a target=\\"_blank\\" href=\\"\\/\d+\\/follow\\" >(\d+)<\\/a>',html))
user_fans.extend(re.findall(r'粉丝<em class=\\"count\\"><a target=\\"_blank\\" href=\\"\\/\d+\\/fans\?current=fans\\" >(\d+)<\\/a>',html))
user_address.extend(re.findall(r'<em class=\\"tit S_txt2\\">地址<\\/em><span>(\S+\s?\S+?)<\\/span>\\r\\n\\t\\t\\t\\t\\t<\\/div>',html))
print('user_id',user_id)
print('user_name',user_name)
print('user_follow',user_follow)
print('user_fans',user_fans)
print('user_address',user_address)
这个url是孙俪的微博账号
下面是她粉丝列表前5页爬到的信息,包括:粉丝ID,粉丝名称,粉丝的关注,粉丝的粉丝量,粉丝的地址

Python爬虫:微博粉丝列表的更多相关文章
- Python 爬虫的工具列表 附Github代码下载链接
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...
- Python 爬虫的工具列表大全
Python 爬虫的工具列表大全 这个列表包含与网页抓取和数据处理的Python库.网络 通用 urllib -网络库(stdlib). requests -网络库. grab – 网络库(基于pyc ...
- Python 爬虫的工具列表
Python 爬虫的工具列表 这个列表包含与网页抓取和数据处理的Python库 网络 通用 urllib -网络库(stdlib). requests -网络库. grab – 网络库(基于pycur ...
- 【转】Python 爬虫的工具列表【预】
这个列表包含与网页抓取和数据处理的Python库 网络 通用 urllib -网络库(stdlib). requests -网络库. grab – 网络库(基于pycurl). pycurl – 网络 ...
- Python 爬虫的工具列表
这个列表包含与网页抓取和数据处理的Python库 网络 通用 urllib -网络库(stdlib). requests -网络库. grab - 网络库(基于pycurl). pycurl - 网络 ...
- [转] Python 爬虫的工具列表 附Github代码下载链接
转自http://www.36dsj.com/archives/36417 这个列表包含与网页抓取和数据处理的Python库 网络 通用 urllib -网络库(stdlib). requests - ...
- 零基础教你写python爬虫
大家都知道python经常被用来做爬虫,用来在互联网上抓取我们需要的信息. 使用Python做爬虫,需要用到一些包: requests urllib BeautifulSoup 等等,关于python ...
- 如何科学地蹭热点:用python爬虫获取热门微博评论并进行情感分析
前言:本文主要涉及知识点包括新浪微博爬虫.python对数据库的简单读写.简单的列表数据去重.简单的自然语言处理(snowNLP模块.机器学习).适合有一定编程基础,并对python有所了解的盆友阅读 ...
- 23个Python爬虫开源项目代码,包含微信、淘宝、豆瓣、知乎、微博等
今天为大家整理了23个Python爬虫项目.整理的原因是,爬虫入门简单快速,也非常适合新入门的小伙伴培养信心,所有链接指向GitHub,微信不能直接打开,老规矩,可以用电脑打开. 关注公众号「Pyth ...
随机推荐
- SAC学习笔记(一)——SAC安装
1.软件包申请 地址: http://www.iris.edu/forms/sac_request.htm 其中的表单需要正确认真填写,选择你所需要的系统平台Linux.Mac OS.Sol ...
- gogland golang 颜色&字体 colors&font 配置文件
<scheme name="Ya" version="142" parent_scheme="Darcula"> <opt ...
- element onclick 动态创建元素并绑定onclick事件
<html> <head> <meta charset="UTF-8"> <title>b</title> <sc ...
- SecondaryNameNode中的“Inconsistent checkpoint fields”错误原因
该错误原因,可能是因为没有设置好SecondaryNameNode上core-site.xml文件中的"hadoop.tmp.dir". 2014-04-17 11:42:18,1 ...
- CodeForces 834D The Bakery(线段树优化DP)
Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredient ...
- ArcGIS应用——使用Python为图斑连续编号及扩展应用
为图斑连续编号 在GIS应用中,为图斑连续编号(编号递增)是一项常见的需求,利用ArcGIS,可以方便的实现. Python脚本如下: rec=0 def autoIncrement(): globa ...
- MacOS安装使用Node.js
1. 到官网https://nodejs.org/zh-cn/download/下载,选择Macintosh Installer, 如下: 2. 按预设的下一步,Node.js版本为v6.10.0, ...
- Docker 1.3.3/1.4.0 发布下载,Linux 容器引擎
Docker 1.3.3 发布,下载地址: https://github.com/docker/docker/archive/v1.3.3.zip 改进记录包括: Security Fix path ...
- mongodb 搭建集群(分片+副本集)
mongodb 搭建集群(分片+副本集) 一.搭建结构图: 二.搭建步骤:
- [SDOI2009] HH的项链 | 莫队模板
题目链接:戳我 题意:求区间中不同颜色的种类数 因为是要过知识点,所以又把这题拿出来做了一遍......这里就写两种方法吧 主席树做法 设pre[i]为第i个点上的颜色在前面序列中出现的最晚的一次的位 ...