抓取单个图片:
#pics.py
"""this is for catching pictures"""
import requests
import re
from bs4 import BeautifulSoup
def catch_onepicture(url,headers):
response = requests.get(url=url,headers=headers)
html = response.text
soup = BeautifulSoup(html,'lxml')
links = soup.find_all('a',class_='mainphoto')
pattern = '<img src="(.*?)" width="457"/>'
link = re