Skip to content

Instantly share code, notes, and snippets.

@fitsum
Last active April 26, 2024 05:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitsum/cfcb26d05ea0c9fac9492ab7e271e1a0 to your computer and use it in GitHub Desktop.
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
// 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)
@fitsum
Copy link
Author

fitsum commented Aug 26, 2023

  • fix spelling 🙄😞

@fitsum
Copy link
Author

fitsum commented Aug 26, 2023

  • 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