一、爱心墙
通过爬虫搜集到粉丝的头像,然后利用 PIL 库拼接出爱心墙的形状
二、代码分析
1.头像爬取
在个人中心点击我的粉丝便可以看到自己的粉丝
通过抓包可知对应的接口为:
url = 'https://me.csdn.net/api/relation/index?pageno=1&pagesize=20&relation_type=fans' # 接口地址
那么,可以定义一个函数来获取粉丝的信息:
def get_fansInfo():
'''
获取粉丝相关信息
'''
url = 'https://me.csdn.net/api/relation/index?pageno=%d&pagesize=%d&relation_type=fans' # 接口地址
cookies = {} # 用户登陆cookies
headers = { # 请求头
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',
'Accept':