import requests as req
from lxml import etree
# 引入webdriver,自动操作chrome浏览器
from selenium import webdriver
# 引入Chrome浏览器插件,相关说明:https://pypi.org/project/webdrivermanager/
from webdriver_manager.chrome import ChromeDriverManager
import os
request_url = 'https://movie.douban.com/subject_search?search_text=王祖贤&cat=1002'
# 可使用XPath helper插件实现,定位对象
src_xpath = "//div[@class='item-root']/a[@class='cover-link']/img[@class='cover']/@src"
title_xpath = "//div[@class='item-root']/div[@class='detail']/div[@class='title']/a[@class='title-text']"
driver = webdriver.Chrome(ChromeDriverManager().install())
picpath = '/Users/nielaishan/Downloads/王祖贤海报'
if not os.path.isdir(picpath):
os.mkdir(picpath)
def download(src, id):
dic = picpath +