Good morning, I am trying to extract from the website https://shop.fattoriaterranova.it/it/14-marmellate the price and cost of each jam jar.
This is my code:
#import modules
import urllib.request, urllib.parse, urllib.error
from urllib import request
from bs4 import BeautifulSoup
import ssl
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
#BeautifulSoup & url
url = 'https://shop.fattoriaterranova.it/it/14-marmellate'
html = request.urlopen(url, context=ctx).read()
soup = BeautifulSoup(html,"html.parser")
results = soup.find(id='product_list')
products = results.find_all('ul', class_='product_list grid row')
print(products)
for product in products:
price_elem = product.find('span', class_='price product-price')
prod_elem = product.find('a', class_='product-name')
if None in (price_elem, prod_elm):
continue
print(price_elem.strip())
print(prod_elem.strip())
print(results.strip())
The output I get is
[ ]
What am I doing wrong?
Thank you