restep_song_random_selector.pyを実行すると曲名が表示されます。- 引数に
1を指定することでコラボ曲も選出対象にできます。- デフォルトでは対象外です。
Last active
November 21, 2020 00:36
-
-
Save mosaicer/da70b78beffc644bc0653f4b11b68bba to your computer and use it in GitHub Desktop.
Re:ステージ!プリズムステップの曲をランダムで選出するPythonスクリプト
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
| import itertools | |
| import random | |
| import requests | |
| import sys | |
| from bs4 import BeautifulSoup | |
| if __name__ == '__main__': | |
| if len(sys.argv) > 2: | |
| raise Exception('Unexpected Arguments {0} : The Argument count must be 2 or less, but it is {1}.'.format(sys.argv, len(sys.argv))) | |
| res = requests.get('https://wikiwiki.jp/re-step/%E6%A5%BD%E6%9B%B2') | |
| soup = BeautifulSoup(res.text, 'html.parser') | |
| tables = soup.find_all(class_='wikiwiki-tablesorter-wrapper') | |
| if len(sys.argv) == 1 or not int(sys.argv[1]): | |
| tables.pop() | |
| print( | |
| random.choice( | |
| list(map( | |
| lambda tr: tr.contents[0].text, | |
| filter( | |
| lambda tr: tr.contents[12].text == '最初から所持' or tr.contents[12].text.endswith('を読む'), | |
| itertools.chain.from_iterable( | |
| map( | |
| lambda table: table.tbody.contents, | |
| tables | |
| ) | |
| ) | |
| ) | |
| )) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment