Last active
December 24, 2024 10:15
-
-
Save paveltretyakovru/95232bd3c6299aa555bc6c22be170e13 to your computer and use it in GitHub Desktop.
Парсинг номера и названия дорожного знака РФ из википедии
This file contains hidden or 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
// https://ru.wikipedia.org/wiki/%D0%94%D0%BE%D1%80%D0%BE%D0%B6%D0%BD%D1%8B%D0%B5_%D0%B7%D0%BD%D0%B0%D0%BA%D0%B8_%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D0%B8 | |
Array.from(document.querySelectorAll('tbody tr:not(:first-child)')) | |
.map(row => { | |
const $point = row.querySelector('td:nth-child(1)'); | |
const $label = row.querySelector('td:nth-child(3)'); | |
if ($point) { | |
return { | |
code: $point.innerText, | |
label: (() => { | |
const countTds = row.querySelectorAll('td').length; | |
switch (countTds) { | |
case 2: return lastLabel; | |
case 3: return lastLabel; | |
default: { | |
if ($label) { | |
lastLabel = $label.innerText; | |
} | |
return lastLabel; | |
} | |
} | |
})(), | |
}; | |
} | |
return null; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment