I developed this simple web scraping program to scrape newegg.com. I made a for loop to print out the name of the product, price, and shipping cost.
However, when I run the for loop it doesn't print out anything and does not give me any error. Before I write the for loop (commented items) I have ran those lines (commented items) and it prints the details only for one of the products.
from bs4 import BeautifulSoup
import requests
import csv
source = requests.get('https://www.newegg.com/PS4-Systems/SubCategory/ID-3102').text
soup = BeautifulSoup(source, 'lxml')
#prod = soup.find('a', class_='item-title').text
#price = soup.find('li', class_='price-current').text.strip()
#ship = soup.find('li', class_='price-ship').text.strip()
#print(prod.strip())
#print(price.strip())
#print(ship)
for info in soup.find_all('div', class_='item-container '):
prod = soup.find('a', class_='item-title').text
price = soup.find('li', class_='price-current').text.strip()
ship = soup.find('li', class_='price-ship').text.strip()
print(prod.strip())
#price.splitlines()[3].replace('\xa0', '')
print(price.strip())
print(ship)
class_='item-container '. change that toclass_='item-container 'But I'm thinking this page is dynamic so you'll need to do some extra work to get the data0divthat yourfind_allcaptures.