-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #1
- Loading branch information
Jeremia
authored and
Jeremia
committed
Jan 7, 2021
1 parent
2124358
commit 215910a
Showing
3 changed files
with
70 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const cheerio = require("cheerio") | ||
const { timeParse } = require("d3-time-format") | ||
const fetch = require("isomorphic-fetch") | ||
|
||
const url = 'http://www.egusd.net/about/leadership/board-of-education/board-meeting-schedule/' | ||
const parseDate = timeParse('%B %e, %Y') | ||
|
||
async function scrapeEGUSDBoard() { | ||
const req = await fetch(url) | ||
const text = await req.text() | ||
const $ = cheerio.load(text) | ||
const calendarIcon = $('.wp-svg-calendar.calendar') | ||
const h3 = calendarIcon.closest('h3') | ||
const ul = h3.next('ul') | ||
const lis = ul.find('li') | ||
const meetings = [] | ||
|
||
lis.each(function(i, li) { | ||
const text = $(li).text() | ||
const [date, ...match] = text.match(/^(\w+\s\d+,\s\d{4})/) | ||
const isRescheduled = text.includes('Rescheduled') | ||
const isWorkshop = text.includes('Board Workshop') | ||
|
||
if (isRescheduled) return | ||
|
||
const parsedDate = parseDate(date) | ||
const title = isWorkshop ? 'EGUSD Board Workshop' : 'EGUSD Board Meeting' | ||
const start = [ | ||
parsedDate.getFullYear(), | ||
parsedDate.getMonth() + 1, | ||
parsedDate.getDate(), | ||
isWorkshop ? 8 : 18, | ||
isWorkshop ? 30 : 0, | ||
] | ||
const duration = { | ||
minutes: isWorkshop ? 390 : 240 | ||
} | ||
|
||
meetings.push({ | ||
title, | ||
description: '', | ||
start, | ||
duration, | ||
}) | ||
}) | ||
|
||
return meetings | ||
} | ||
|
||
module.exports = scrapeEGUSDBoard |
This file contains 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