|
# coding:utf-8
# 引入相关模块
import requests, os
from bs4 import BeautifulSoup
url = "https://book.douban.com/"
da = requests.get(url).text
# 对获取到的文本进行解析
soup = BeautifulSoup(da, 'lxml')
# 从解析文件中通过select选择器定位指定的元素,返回一个列表
news_titles = soup.select("div.cover > a > img")
# 对返回的列表进行遍历
for n in news_titles:
link = n.get("src")
# print(link)
data = open(os.path.join(r'E:\Vbox\Python Program\download', os.path.basename(link)), 'wb')
|
-
本地图片为0kb
|