import os
import requests
from bs4 import BeautifulSoup
base_path = os.path.dirname(os.path.abspath(__file__))
img1_path = os.path.join(base_path,"img1")
response = requests.get("http://pic.yesky.com/koreastar/album/381/421714881.shtml")
soup = BeautifulSoup(response.text,"html.parser")
div_obj = soup.find(name = "div",attrs={"class":"viewport"})
list_dl = div_obj.find_all(name = "li")
for li in list_dl:
img = li.find(name = "img")
img_src = img.get("src")
img_response = requests.get(img_src)
file_path = os.path.join(img1_path,img_src.rsplit("/",1)[-1])
with open(file_path,"wb") as f:
f.write(img_response.content)
效果图:

 爬天极网美女预览图版一: 随笔

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。