I´m trying to scrape the price information for the products in the site using Beautiful Soup: 'https://www.compracerta.com.br/celulares-e-smartphones?page=1'
But the price returns an empty list i.e. []
.
Below my code:
from pandas_datareader import data as pdr
import numpy as np
import pandas as pd
from selenium import webdriver
import matplotlib.pyplot as plt
from datetime import datetime,timedelta
from bs4 import BeautifulSoup
import requests
import math
import re
from requests_html import HTMLSession, AsyncHTMLSession
from lxml import etree
import xlwt
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
url_pag='https://www.compracerta.com.br/celulares-e-smartphones?page=1'
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"}
executable_path = r'C:\Users\vinig\Downloads\chromedriver_win32\chromedriver.exe'
browser = webdriver.Chrome(executable_path=executable_path)
browser.get(url_pag)
html = browser.page_source
soup = BeautifulSoup(html, 'lxml')
produtos = soup.find_all('div', class_="gallery-container shelf prateleira default n12colunas")
for produto in produtos:
marca = produto.find('a', attrs={'class':"image"})
preco = produto.find('div', attrs={'class':"price"})```
The result is:
The Elements Page is: