-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
63 lines (47 loc) · 1.51 KB
/
utils.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from bs4 import BeautifulSoup
def read_main_html(filename):
file = open(filename, 'r')
html = file.read()
soup = BeautifulSoup(html, "html.parser")
file.close()
return soup
def print_row(session_name, venue, session_type, session_time):
return session_name + "|" \
+ venue + '|' \
+ session_type + '|' \
+ session_time
def get_times(link):
result = "no times"
sessionTimes = __getSessionTimesDiv(link)
tooltip = sessionTimes.find('div', attrs={'class':'tooltip'})
if tooltip:
result = tooltip.next_sibling
else:
print('no tooltip')
return result
def get_venue(link):
result = "no venue"
sessionTimes = __getSessionTimesDiv(link)
venue = sessionTimes.find('span', attrs={'class':'sessionRoom'})
if venue:
result = venue.text[2:]
result = result.strip()
else:
print('no venue')
return result
def get_session_name(soup):
result = 'No Name!!'
abbreviation = soup.find('span', attrs={'class':'abbreviation'})
title = soup.find('span', attrs={'class':'title'})
if abbreviation and title:
result = abbreviation.text + title.text
return result
def get_session_type(link):
result = 'No type!!'
session_type = link.parent.find('small', attrs={'class':'type'})
if session_type:
result = session_type.text
return result
# private methods
def __getSessionTimesDiv(link):
return link.parent.parent.find('div', attrs={'class':'sessionTimes'})