关于前面的知识点可以通过下面链接对比查看爬虫学习1--使用requests库与re库对网页进行爬取示例讲解_我就是一个小怪兽的博客-CSDN博客
图片来源于网络随意找到的一个图库,
import requests
from bs4 import BeautifulSoup
url='https://www.woyaogexing.com/shouji/'
r=requests.get(url,verify=False)
r.encoding='utf-8'
tt=r.text#获取需要的源代码
main_page=BeautifulSoup(tt,'html.parser')
imgs=main_page.find_all('a',attrs={'class':'img'})
for img in imgs:
big_link=img.find('img',attrs={'class':'lazy'}).get('src')#使用get获取标签中的属性src
img_name=big_link.split('/')[-1]
print(big_link)
print('over '+img_name)
img_resp=requests.get('http:'+big_link,verify=False,headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0;