-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhello.py
More file actions
57 lines (45 loc) · 1.58 KB
/
Copy pathhello.py
File metadata and controls
57 lines (45 loc) · 1.58 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from urllib.request import urlopen
import re
'''
Function that asks you for your breakfast choice with input requests.
Args:
None
Returns:
None
'''
def AskBreakfast():
breakfast = input("Hello there! What did you have for breakfast today? ")
if breakfast == "" or breakfast == "Nothing":
print("Nothing really? How are going to survive this day?")
else:
print("You had " + breakfast + " for breakfast? That sounds really awful! You disgust me!")
'''
Function that asks you for your breakfast choice with input requests.
Args:
None
Returns:
None
'''
def AskDinner():
dinner = input("What did you have for dinner? ")
if dinner == "" or dinner == "Nothing" and AskBreakfast == "" or AskBreakfast == "Nothing":
print("Nothing for breakfast and dinner? Are you trying to starve yourself?")
elif dinner == "" or dinner == "Nothing":
print("Nothing really? Are you on a diet?")
else:
print("You had " + dinner + " for dinner? That sounds terrible. Your food choices are really questionable! You need help!")
url="https://www.timeanddate.de/"
page=urlopen(url)
html_bytes = page.read()
html = html_bytes.decode("utf-8")
pattern='<span id="clk_hm">.*?</span>'
match_results = re.search(pattern, html, re.IGNORECASE)
title = match_results.group()
title = re.sub("<.*?>", "", title)
pattern_2='<span id="ij0">.*?</span>'
match_results_2 = re.search(pattern_2, html, re.IGNORECASE)
title_2 = match_results_2.group()
title_2 = re.sub("<.*?>", "", title_2)
print("The current time is: " + title + ":" + title_2 )
AskBreakfast()
AskDinner()