Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
Last active January 1, 2018 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuya-takeyama/267571869535ce563ddb241c7ee358c3 to your computer and use it in GitHub Desktop.
Save yuya-takeyama/267571869535ce563ddb241c7ee358c3 to your computer and use it in GitHub Desktop.
エケペディアの欅坂46メンバー一覧ページから誕生日データを抽出する
JSON.stringify(Array.from(document.querySelectorAll('.sortable.wikitable.jquery-tablesorter')[0].querySelectorAll('tbody tr')).map(e => { return { name: e.querySelectorAll('td')[2].querySelector('a').innerText, kana: e.querySelectorAll('td')[2].querySelector('rt').innerText, birthday: e.querySelectorAll('td')[3].innerText.match(/(\d{4})年(\d+)月(\d+)日/) } }).map(d => { return { name: d.name, lastNameKana: d.kana.split(' ')[0], firstNameKana: d.kana.split(' ')[1], birthday: [parseInt(d.birthday[1], 10), parseInt(d.birthday[2], 10), parseInt(d.birthday[3], 10)] }; }).map(d => { return { ...d, birthday: '' + d.birthday[0] + '-' + (d.birthday[1] < 10 ? '0' : '') + d.birthday[1] + '-' + (d.birthday[2] < 10 ? '0' : '') + d.birthday[2] }; }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment