forked from erunpie/inline-measurement
-
Notifications
You must be signed in to change notification settings - Fork 2
/
horoscope.py
41 lines (34 loc) · 990 Bytes
/
horoscope.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
31
32
33
34
35
36
37
38
39
40
41
import string
import xml.etree.ElementTree as ET
from xml.etree import ElementTree
from xml.etree.ElementTree import Element
import requests
apiSigns = {
"Овен": "aries",
"Телец": "taurus",
"Близнецы": "gemini",
"Рак": "cancer",
"Лев": "leo",
"Дева": "virgo",
"Весы": "libra",
"Скорпион": "scorpio",
"Стрелец": "sagittarius",
"Козерог": "capricorn",
"Водолей": "aquarius",
"Рыбы": "pisces"
}
apiDays = {
"Сегодня": "today",
"Завтра": "tomorrow",
"Вчера": "yesterday"
}
def request():
response = requests.get("https://ignio.com/r/export/utf/xml/daily/com.xml").text
return ET.fromstring(response)
def getHoro(horoscope, sign):
level = sign + "/" + "today"
date = None
for tag in horoscope.findall('date'):
date = tag.get('today')
for tag in horoscope.findall(level):
return ' ' + date + ':' + tag.text