#selenium如何爬取图片地址
#小白一人,正在学习python,使用selenium爬图片地址最后一步不知道怎么写,请大神帮忙
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
import time
from selenium import webdriver
web =webdriver.Edge()
web.get('https://bk.wzxsjw.com/electronicbook')
time.sleep(3)
utllist1 =web.find_elements(By.CLASS_NAME,'coverDiv___rhKSe')
for utl in utllist1:
utl.click()
time.sleep(2)
utllist2 = web.find_elements(By.CLASS_NAME, 'coverDiv___rhKSe')
for utl2 in utllist2:
utl2.click()
time.sleep(2)
utllist3 = web.find_elements(By.CLASS_NAME, 'wrapper___VNdjv')
for utl3 in utllist3:
utl3.click()
time.sleep(2)
utllist4 = web.find_elements(By.CLASS_NAME, 'adm-swiper-slide')
for utl4 in utllist4:
utl4 =web.find_element(By.XPATH, '.div/div/img')
utl5=utl4.get_attribute('href')
#这个地方如何把图片地址提出来#
print(utl5)
time.sleep(100)
字符串处理就行了,吧前面的href=去掉就行,字符串可以用[:]来取,或者用replace来吧前面的href替代为空字符串
还差一步,就爬出了第一张,后面几张没出来,我再想想
如有侵权,联系删除 csl184548@163.com