为什么我的代码只下载了16张图片?
enter link description here
driver.get(url)
driver.implicitly_wait(50)
for x in range(7):
driver.execute_script("window.scrollBy(0, 200)")
sleep(0.5)
driver.find_element(By.CLASS_NAME, "facetwp-load-more").click()
counter = 1
for i in driver.find_elements(By.XPATH,"/html/body/div[6]/div[2]/div/div/div/div/div/div[1]/a/div/img"):
atributoSrc = i.get_attribute("src")
file_name = f"image{counter:02d}.jpg"
imagem.append(atributoSrc)
urllib.request.urlretrieve(atributoSrc,f"C:\\__Imagens e Planilhas Python\\Facebook\\Imagens\\ImagensJPG\\{file_name}")
counter += 1
1条答案
按热度按时间oknwwptz1#
我创建了一个https://github.com/seleniumbase/SeleniumBase脚本,将所有这些图像作为文件下载:
已成功下载所有图像。