Last active
April 19, 2017 00:16
-
-
Save dwillis/5f39e2ecb8c4694c28294448e677d53b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import requests | |
from BeautifulSoup import BeautifulSoup | |
import time | |
import datetime | |
today = str(datetime.date.today().month)+'/'+str(datetime.date.today().day)+'/'+str(datetime.date.today().year) | |
url = "http://browse.calendar.gwu.edu/EventList.aspx?fromdate=%s&todate=%s&view=DateTime&display=Day&type=public" % (today, today) | |
response = requests.get(url) | |
html = response.content | |
soup = BeautifulSoup(html) | |
table = soup.find('table', id="tblEvents") | |
list_of_rows = [] | |
for row in table.findAll('tr')[2:]: | |
list_of_cells = [] | |
for cell in row.findAll('td'): | |
list_of_cells.append(cell.text.encode('utf-8')) | |
list_of_rows.append(list_of_cells) | |
outfile = open("events2.csv", "wb") | |
writer = csv.writer(outfile) | |
writer.writerow(["time", "url", "text"]) | |
writer.writerows(list_of_rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment