-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscrape3.py
More file actions
23 lines (18 loc) · 790 Bytes
/
scrape3.py
File metadata and controls
23 lines (18 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from bs4 import BeautifulSoup
from urllib2 import urlopen
BASE_URL = "http://www.newhavenarts.org/calendar/calendar_embed.php"
def get_today_events(section_url):
html = urlopen(section_url).read()
soup = BeautifulSoup(html, "lxml")
# calendar = soup.find("td", "bodytext")
events_header = [div.strong for div in soup.findAll("div", "cal_header_title")]
events_who = [div for div in soup.findAll("div", "cal_column_1")]
events_when = [div for div in soup.findAll("div", "cal_column_2")]
events_where = [div for div in soup.findAll("div", "cal_column_3")]
return {"events_header": events_header,
"events_who": events_who,
"events_when": events_when,
"events_where": events_where}
if __name__ == '__main__':
events = get_today_events(BASE_URL)
print 'Events: ', events