Skip to content

Added support for checking last 3(multiple) notifications. #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

NO_OF_NOTIFICATION_TO_BE_CHECKED = 3

# smtp connection
def Sendemail(date,Notification, link,receivers_email):
Expand Down Expand Up @@ -53,8 +54,6 @@ def Sendemail(date,Notification, link,receivers_email):
except Exception as e:
print(e)

h3_tag=html.find("h3",{"class":"d-block"})

#memory of code

l =os.environ.get('EMAIL_LIST')
Expand All @@ -78,28 +77,38 @@ def Convert(string):
def info():

#date
dt = (html.find("p",{"id":"ContentPlaceHolder1_lvCircular_lblUploadDate_0"})).text
link_tag=h3_tag.find("a",{"target" :"_blank"},href=True)
link= link_tag.get('href')

notificationToBeAddedFrom = NO_OF_NOTIFICATION_TO_BE_CHECKED
for index in range(NO_OF_NOTIFICATION_TO_BE_CHECKED,0,-1):
h3_tag = html.find("p",{"id":"ContentPlaceHolder1_lvCircular_lblUploadDate_" + str(index - 1)}).parent.find("h3",{"class":"d-block"})
dt = (html.find("p",{"id":"ContentPlaceHolder1_lvCircular_lblUploadDate_" + str(index - 1)})).text
link_tag=h3_tag.find("a",{"target" :"_blank"},href=True)
link= link_tag.get('href')
if(link==recorded): # if link matches to already recorded, from here on all notifications are new
notificationToBeAddedFrom = index - 1
break

print("Current Link :"+link)
if recorded != link:
try:
# msg = (dt + "\n\n"+link_tag.text+ "\n\n"+link + "\n")
for email in L:
Sendemail(dt,link_tag.text,link,email)
print("Mail sended successfully")

with open("Record", 'wb') as f:
pickle.dump(link, f)
print("link is Successfully added to code memory")

except Exception as e:
print("Error : ")
print(e)


if(notificationToBeAddedFrom != 0):
print("No of new notifications came - " + str(notificationToBeAddedFrom))
for index in range(notificationToBeAddedFrom,0,-1):
h3_tag = html.find("p",{"id":"ContentPlaceHolder1_lvCircular_lblUploadDate_" + str(index - 1)}).parent.find("h3",{"class":"d-block"})
dt = (html.find("p",{"id":"ContentPlaceHolder1_lvCircular_lblUploadDate_" + str(index - 1)})).text
link_tag=h3_tag.find("a",{"target" :"_blank"},href=True)
link= link_tag.get('href')
print("Current Link :"+link)
if recorded != link:
try:
# msg = (dt + "\n\n"+link_tag.text+ "\n\n"+link + "\n")
for email in L:
Sendemail(dt,link_tag.text,link,email)
print("Mail sended successfully")

with open("Record", 'wb') as f:
pickle.dump(link, f)
print("link is Successfully added to code memory")

except Exception as e:
print("Error : ")
print(e)
else:
print("No latest notification")

Expand Down