I'm learning about web scraping and now I want to know if is possible to extract a image from a website and put in to a excel file?
I'm working in this website:https://www.browniespain.com/es/novedades/
And here my code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import os
import openpyxl
from openpyxl import Workbook
import time
browser=webdriver.Safari()
browser.get("https://www.browniespain.com/es/novedades/")
primera = "//*[@id='center_column']/div[6]/div["
segunda ="]/div/div[2]/div[1]/h5/a"
productos = len(browser.find_elements_by_xpath('//*. [@id="center_column"]/div[6]/div'))
print(productos)
for n in range(1,productos+1):
direccion = primera+str(n)+segunda
nombre_producto = browser.find_element_by_xpath(direccion).text
file_name = 'NovedadesBrownie.xlsx'
if(os.path.exists(file_name)):
workbook = openpyxl.load_workbook(file_name)
worksheet = workbook.get_sheet_by_name('Sheet')
else:
workbook = Workbook()
worksheet = workbook.active
worksheet.cell(row=n,column=1).value = nombre_producto
workbook.save(file_name)
print(nombre_producto)
primera = "//*[@id='center_column']/div[6]/div["
segunda ="]/div/div[2]/div[1]/div[2]/span"
productos = len(browser.find_elements_by_xpath('//*[@id="center_column"]/div[6]/div'))
print(productos)
for n in range(1,productos+1):
direccion = primera+str(n)+segunda
precio_producto = browser.find_element_by_xpath(direccion).text
if(os.path.exists(file_name)):
workbook = openpyxl.load_workbook(file_name)
worksheet = workbook.get_sheet_by_name('Sheet')
else:
workbook = Workbook()
worksheet = workbook.active
worksheet.cell(row=n,column=2).value = precio_producto
workbook.save(file_name)
print(precio_producto)
browser.close()
Do you know any idea to extract the images and put in that Excel file?