-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwdt.py
30 lines (27 loc) · 851 Bytes
/
wdt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## This is a test comment for git commit 2
import requests
import urllib.request
from datetime import datetime
import time
from bs4 import BeautifulSoup
import os
#class="scene__title-link"
url = 'https://www.duden.de/wort-des-tages'
response = requests.get(url)
#print(soup.prettify())
soup = BeautifulSoup(response.text, 'html.parser')
word = {}
wordexp = {}
for a in soup.findAll('a', {'class': 'scene__main'}):
wordexp = a.text.strip()
for a in soup.findAll('a', {'class': 'scene__title-link'}):
word = a.text.strip()
message = word + ' - ' + wordexp
now = datetime.now()
dt_string = now.strftime("%d-%m-%Y-%H-%M-%S")
myfile = "/home/mgmtadmin/wdt/wdt-" + dt_string
f = open(myfile, "w")
f.write("Subject:"+word+"\n"+message+"\n")
f.close()
sendmail = '/usr/sbin/sendmail [email protected] < ' + myfile
os.system(sendmail)