Last active
April 26, 2024 05:18
-
-
Save fitsum/cfcb26d05ea0c9fac9492ab7e271e1a0 to your computer and use it in GitHub Desktop.
Extract a nice JSON of Trump, his 18 co-conspirators and what they're charged with from CNN's post
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
// Go here - https://www.cnn.com/interactive/2023/08/georgia-indictment-defendants-list-dg/ | |
// Open dev tools and paste what's below in Console tab | |
// Option 1: uncomment and run the first 'getEm' function for an unnumbered list of charges per defendant | |
// Option 2: uncomment and run the second 'getEm' function for an numbered list of charges per defendant | |
const getEm = ( numbered ) => { | |
const addNumberIfNumbered = index => numbered ? `${index + 1 + '. '}` : '' | |
return $$( '.charges-container' ).map( ( container, idx ) => { | |
const header = container.parentElement.querySelector( '.header' ) | |
const name = header.querySelector( '.name' ).textContent | |
const title = header.querySelector( '.title' ).textContent | |
const list = container.querySelector( '.charges' ).children | |
return {['defendant']: { [ 'name' ]: name, [ 'title' ] : title,[ 'charges' ]: [ ...list ].map(( item, idx ) => { | |
return `${addNumberIfNumbered(idx)}${item.textContent}` | |
}) | |
}}}) | |
} | |
// no numbers | |
// getEm() | |
// totes numbered | |
// getEm(true) |
Author
fitsum
commented
Aug 26, 2023
- fix spelling 🙄😞
- add separate fields for name, title and charges
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment