Skip to content

Commit

Permalink
start tracking with git
Browse files Browse the repository at this point in the history
  • Loading branch information
ciolt committed Sep 2, 2019
0 parents commit f0736da
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Folders
node_modules
.vscode
.DS_Store
logs

# Files
.env
*.log
*.DS_Store
tmp/
48 changes: 48 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const axios = require('axios')
const cheerio = require('axios')
const fs = require('fs')
const officeHolders = require('./office-holders')

const START_DATE = '06-18-1996'
const END_DATE = '08-25-2019'

const genURL = officeHolder => `https://www.miamidade.gov/govaction/Votingrecord.asp?` +
`begdate=${START_DATE}&` +
`enddate=${END_DATE}&` +
`OfficeHolders=${officeHolders[officeHolder]}&` +
`MatterType=AllMatters&` +
`BodyType=AllBodies` +
`&submit1=Submit`

const allObjs = document.querySelectorAll('tr[valign="top"]')
const combinedRecords = (() => {
let cr = []
for (let i = 0; i < allObjs.length; i += 1) {
var currentObj = allObjs[i]
switch (i % 3) {
case 0: // 1st line
cr.push([currentObj]); break
case 1:
case 2:
cr[cr.length - 1].push(currentObj); break
}
}
return cr
})()

const resolutions = (() => {
const r = {}
combinedRecords.forEach(a => {
var id = Number(Array.from(a[0].querySelectorAll('b'))[0].innerText)
var name = String(Array.from(a[0].querySelectorAll('b'))[1].innerText)
var type = String(Array.from(a[0].querySelectorAll('b'))[2].innerText)
var description = String(Array.from(a[1].querySelectorAll('b'))[1].innerText)
var resolutionFull = String(Array.from(a[2].querySelectorAll('b'))[1].innerText)
var date = resolutionFull.match(/([0-9]){1,2}\/([0-9]){1,2}\/([0-9]){4}/g)[0]
var resolution = resolutionFull.split(date)[1]
r[id] = {
id, name, type, description, date, resolution
}
})
return r
})()
37 changes: 37 additions & 0 deletions office-holders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const officeHolders = {
54: 'Betty T. Ferguson',
55: 'James Burke',
56: 'Arthur E. Teele, Jr.',
57: 'Gwen Margolis',
58: 'Bruce C. Kaplan',
59: 'Pedro Reboredo',
60: 'Maurice A. Ferre',
61: 'Katy Sorenson',
62: 'Dennis C. Moss',
64: 'Miguel Diaz de la Portilla',
65: 'Alexander Penelas',
249: 'Dr. Miriam Alonso',
251: 'Jimmy L. Morales',
352: 'Bruno A. Barreiro',
427: 'Natacha Seijas',
431: 'Joe A. Martinez',
455: 'Rebeca Sosa',
476: 'Dr. Barbara Carey-Shuler',
486: 'Sen. Javier D. Souto',
495: 'Jose "Pepe" Cancio, Sr.',
505: 'Jose "Pepe" Diaz',
506: 'Sally A. Heyman',
507: 'Dorrin Rolle',
554: 'Carlos A. Gimenez',
555: 'Barbara J. Jordan',
571: 'Audrey M. Edmonson',
625: 'Lynda Bell',
626: 'Jean Monestime',
641: 'Esteban L. Bovo, Jr.',
642: 'Xavier L. Suarez',
663: 'Juan C. Zapata',
676: 'Daniella Levine Cava',
699: 'Eileen Higgins'
}

module.exports = officeHolders
185 changes: 185 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "voting-scraper",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"cheerio": "^1.0.0-rc.3"
}
}

0 comments on commit f0736da

Please sign in to comment.