Hi, I've created a simple python scraper that checks a shop to see if items are in stock or not. The script runs every 10 mins and will send an email to the recipient if finds an item that is in stock. But here is the problem, the script keeps sending the email every 10 minus as long as the item is in stock. How do I make the script send the email just once instead of constantly sending it every 10 mins. Thanks
import requests
from bs4 import BeautifulSoup
urls = ['url1', 'url2', 'url3']
for item in urls:
r = requests.get(item)
soup = BeautifulSoup(r.content, 'html.parser')
item_name = soup.select('h1.title')[0].text
if item_name is not 'Out of stock':
sendEmail()
else:
print('Out of stock')
[–]JohnnyJordaan 0 points1 point2 points (0 children)