Python Forum
How to make scraper send email notification just once
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make scraper send email notification just once
#1
Hi, I've created a simple python scraper with beautifulsoup that checks a site every 5 minutes to see if it contains the word 'dog'. If the word is present, the script will send an email to the recipient. The problem is that, the script keeps sending the email every 5 minutes as long as the word dog is on the site. How do I make the script send the email just once instead of constantly every 5 mins. Thanks.

import requests
from bs4 import BeautifulSoup


url = "https://justpaste.it/4f4jb"
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')

if 'dog' in soup.text:
    print('Email Sent')
else:
    print('Nothing found')    
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sound Sensor With EMail Notification parascand 1 478 Dec-10-2023, 03:10 AM
Last Post: deanhystad
  Send email with smtp without using Mimetext mgallotti 0 706 Feb-01-2023, 04:43 AM
Last Post: mgallotti
  email Library: properly send message as quoted-printable malonn 3 1,311 Nov-14-2022, 09:31 PM
Last Post: malonn
  Error notification after encoding robertje1024 1 1,194 May-29-2022, 04:18 PM
Last Post: Axel_Erfurt
  Unable to send email attachments cosmarchy 7 2,534 Mar-09-2022, 09:29 PM
Last Post: bowlofred
  Web Scraper with BeautifulSoup4 sometimes no Output Nitsuj 2 1,943 Nov-26-2021, 05:04 PM
Last Post: snippsat
  Can't read virtual pin or use notification on blynk flypon 1 3,122 Oct-28-2021, 02:32 PM
Last Post: ChanceTran
  send email smtp rwahdan 0 1,782 Jun-19-2021, 01:28 AM
Last Post: rwahdan
  Need Outlook send email code using python srikanthpython 3 8,210 Feb-28-2021, 01:53 PM
Last Post: asyswow64
  running python script showing an icon in the tray notification area chubbychub 1 4,559 Nov-01-2020, 03:52 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020