Metainformationen zur Seite
URL/Webseite mit Python überwachen
#!/usr/bin/python3 import requests # Import requests (to download the page) import hashlib #Import hashlib zum Seite vergleichen import smtplib# Import smtplib (to allow us to email) import time# Import Time (to add a delay between the times the scape runs) #Variablen fromemail= "" toemail= "" smtpserver= "" mypasswd ="" while True: url="https://de.wikipedia.org/wiki/Wikipedia:Testseite" #Hash der bisherigen Seite oldmd5 = "10f056ec6ae0d249d86b3829a527321b" #Seite runterladen r = requests.get(url) #Text encoden -> MD5 Hash bilden-> als hex darstellen newmd5 = hashlib.md5(r.text.encode()).hexdigest() print(time.ctime(time.time())+" Old Hash: "+oldmd5) print(time.ctime(time.time())+" New Hash: "+newmd5) if( oldmd5 == newmd5): #Zeit in Sekunden time.sleep(60*60) continue else: #Alles von https://chrisalbon.com/python/web_scraping/monitor_a_website/ # create an email message with just a subject line, msg = 'Subject: Seite checken' print(msg) # set the 'from' address, ##fromaddr = fromemail # set the 'to' addresses, #toaddrs = ['AN_EMAIL_ADDRESS','A_SECOND_EMAIL_ADDRESS', 'A_THIRD_EMAIL_ADDRESS'] ##toaddrs = [toemail] # setup the email server, ##server = smtplib.SMTP(smtpserver, 587) ##server.starttls() # add my account login name and password, ##server.login(fromemai, mypasswd) # Print the email's contents ##print('From: ' + fromaddr) ##print('To: ' + str(toaddrs)) ##print('Message: ' + msg) # send the email ## server.sendmail(fromaddr, toaddrs, msg) # disconnect from the server ## server.quit() break