requests爬虫案例
1.使用requests库爬取微信公众号“Python小屋”文章“Python使用集合实现素数筛选法”中的所有超链接。
import requests
url = 'https://mp.weixin.qq.com/s?__biz=MzI4MzM2MDgyMQ==&mid=2247486531&idx=1&sn=7eeb27a03e2ee8ab4152563bb110f248&chksm=eb8aa719dcfd2e0f7b1731cfd8aa74114d68facf1809d7cdb0601e3d3be8fb287cfc035002c6#rd'
r = requests.get(url)
r.status_code #响应状态码
200
r.text[:300] #查看网页源代码前300个字符
<!--返回内容-->
'<!DOCTYPE html>\n<!--headTrap<body></body><head></head><ht