Created
September 27, 2024 22:22
-
-
Save ricealexander/d5328aa10bb9c7b398cab74b0d910b62 to your computer and use it in GitHub Desktop.
Collect improperly formatted person page URLs in Grove
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
const staffLinks = [] | |
setInterval(() => { | |
const bylines = document.querySelectorAll('[class*="Promo"][class*="-authorName"] .Link') | |
for (let byline of bylines) { | |
let href = byline.href | |
if (href.endsWith('-1') // 1. Look for duplicate permalinks | |
|| href.split('-').length > 3 // 2. Look for partner organizations | |
) { | |
staffLinks.push(href) | |
continue | |
} | |
if ( !href // 3. Skip invalid links | |
|| href.startsWith('https://www.stlpr.org/people/') // a. Skip links that already match our desired format | |
|| !href.startsWith('https://www.stlpr.org/') // b. Skip partner station links | |
|| staffLinks.includes(href) // 4. Skip links we've already noted | |
) continue | |
staffLinks.push(href) // 4. Catch all links that remain | |
} | |
}, 1000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment