Last active
February 18, 2016 18:03
-
-
Save akahana-1/996e10a4e128a47d4726 to your computer and use it in GitHub Desktop.
クリアランプマネージャーから一括でクリアランプを持ってくる
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
#! /usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
#requirement : lxml | |
import lxml.html | |
import urllib.request as req | |
LAMP_URL = "http://www.beatmania-clearlamp.com/djdata/%s/sp/" | |
# 取得したいユーザのクリアランプマネージャでのユーザ名 | |
DJ_NAME = "GOAL" | |
html = req.urlopen(LAMP_URL % DJ_NAME).read() | |
dom = lxml.html.fromstring(html) | |
# 難易度一覧 | |
difficults = [ | |
"NORMAL", | |
"HYPER", | |
"ANOTHER", | |
] | |
difficult = "ANOTHER" | |
# wanna get clear lamp level. if empty string, get all clear lamp. | |
level = "12" | |
lampdatas = dom.xpath("//div[@class='list']") | |
lamps = dict() | |
""" | |
lamps内にクリア状況が入る | |
それぞれ | |
"曲名" : "クリア状況"の形式 | |
クリア状況は | |
"NO" : NO PLAY | |
"F" : FAILED | |
"A" : ASSIST | |
"E" : EASY | |
"C" : CLEAR | |
"H" : HARD | |
"EX" : EX HARD | |
"FC" : FULL COMBO | |
""" | |
for data in lampdatas: | |
musicdatas = data.xpath("descendant::dl") | |
for mdata in musicdatas: | |
# 難易度 | |
d = mdata.xpath("self::dl")[0].attrib["class"].split(" ")[-1].upper() | |
#クリアランプ | |
l = mdata.xpath("descendant::dt")[0].attrib["class"] | |
#曲名 | |
n = mdata.xpath("descendant::dd[@class='musicName']")[0].text | |
f = True | |
if level: | |
f = bool(len(mdata.xpath("descendant::dd[@class='level l%s']" % level))) | |
if f: | |
lamps[n] = l | |
print(lamps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment