0

I need the data from this interactive map. From "inspect element," I can see that the data is available but don't know how to get it into a spreadsheet. I would like to scrape the FIPS code and jail incarceration rate for each county. Does anyone know where to start?

hjohns12
  • 11
  • 5

2 Answers2

0

I'd suggest using CSS selectors (http://www.w3schools.com/cssref/css_selectors.asp). In your case, "counties county" should be working as selector.

You can implement it with Nokogiri (http://www.nokogiri.org/) on Ruby.

mikey
  • 161
  • 9
0

A quick glance into the network tab in JavaScript console reveals that when you click on a state a http call is made to the server to load the necessary information

http://trends.vera.org/data/state/19 

this is the link which loads data for the state of Iowa, Indiana is 18 ( http://trends.vera.org/data/state/18)

you should be able to parse the JSON in response and store in excel using any online tools like (http://www.json-xls.com/).

Good luck

Anantha Sharma
  • 9,920
  • 4
  • 33
  • 35
  • Can you please provide more detail as to how this would be done? I do not know how to "parse the JSON in response." I need to data for each individual county, not state-level aggregate measures. Thank you for the help. – hjohns12 Jan 03 '17 at 19:18
  • Open `http://www.json-xls.com/json2xls` select `URL` tab, now paste the verga URL (`http://trends.vera.org/data/state/19 `) and select layout as auto, click `Both` in select view rendering.. a Excel file will get downloaded with the JSON content. – Anantha Sharma Jan 03 '17 at 19:23
  • With that method, I would have to manually open all 3,000 county URLs and download them individually. I'm hoping for a method that automatizes this entire process. – hjohns12 Jan 03 '17 at 19:30
  • an `Excel VBA script`, `Python` are all tools which can help you with this.. but I don't think there is any existing solution that exists.. google will be your best friend in this regard. – Anantha Sharma Jan 03 '17 at 19:42
  • This (tablib) Python Library can be of help here.. http://stackoverflow.com/questions/15379178/json-conver-to-xls-in-python – Anantha Sharma Jan 03 '17 at 19:53