I've recently learned about web scraping and wanted to create a program that scraped daily product prices. I'm using requests and bs4 in python to scrape target.com. So far this is my code:
TIMES = [2, 3, 4, 5, 6, 7]
url = 'https://www.target.com/p/dyson-ball-animal-2-upright-vacuum-iron-purple/-/A-52190951'
sleep(choice(TIMES))
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
sleep(choice(TIMES))
name = soup.find('h1').get_text().strip().replace(',', ';')
print('Product name: ', name)
sleep(choice(TIMES))
current_price = soup.find('span', {'data-test': 'product-savings'})
print('Current price: ', current_price)
When I run my code, the product name is correct, but the current price is always "None". Is there a different way I should be searching for the product price?
Thanks in advance!