So I have a web scraping script from a retail site and I have been scraping names and prices into an excel successfully. I wanted to create more scripts for other products on the same site as well but am having some trouble. Basically in my other scripts I could reach the price by only using 1 container. With this however I had to make another container that is deeper because I don't know how to skip div and span classes. So I had to make 2 for loops as you see and I get the results I want however when exported to excel it exports everything in the first column only. It would help if there was a way to skip classes so that I can only use 1 for loop like previously, or a way to manipulate to data so that I move it to the second column.
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
import requests
import os.path
page_url = "https://www.tenniswarehouse-europe.com/catpage-MSNIKE-EN.html"
save_path = 'C:\\Users\\Lefty\\Desktop\\Scrape Excels'
response = requests.get(page_url, cookies={'SMID':'smc_fbIdmC7VmLvxzHBD0pXTqbYo7kSYh69hqcKQ02xE_239306669'})
soup = soup(response.text, 'html.parser')
containers = soup.findAll("div", {"class":"product_wrapper shoe cf"})
containers1 = soup.findAll("div", {"class":"pricing"})
filename = "Nikes Men's Shoes"
completeName = os.path.join(save_path, filename+".csv")
f = open(completeName, 'w')
headers = "Name, Price\n"
f.write(headers)
for container in containers:
name = container.div.img['alt']
f.write(name + "," + '\n')
for container1 in containers1:
price = container1.span.span.text
f.write(price.replace(",", ".") + '\n')