コード例 #1
0
ファイル: kajiwara_23.py プロジェクト: m-note/100knock2015
def main():
    text = mogura.get_country_text(u"イギリス", mogura.get_country())
    section_list = [line.strip() for line in text.split("\n") if line.startswith("==")]
    print "\n".join([section+"\t"+str(section.count("=")/2-1) for section in section_list])
コード例 #2
0
ファイル: kajiwara_24.py プロジェクト: m-note/100knock2015
def main():
    text = mogura.get_country_text(u"イギリス", mogura.get_country())
    print "\n".join([line.strip() for line in text.split("\n") if line.startswith("[[ファイル:")])
コード例 #3
0
ファイル: kajiwara_22.py プロジェクト: m-note/100knock2015
def main():
    text = mogura.get_country_text(u"イギリス", mogura.get_country())
    category_list = [line.strip() for line in text.split("\n") if line.startswith("[[Category:")]
    print "\n".join([line.split("|")[0].replace("[[Category:", "").replace("]]", "") for line in category_list])
コード例 #4
0
ファイル: kajiwara_25.py プロジェクト: m-note/100knock2015
def get_infobox(country):
    text = mogura.get_country_text(country, mogura.get_country())
    infobox = [line.strip() for line in text.split("\n}}\n")[0].split("\n") if line.startswith("|")]
    return dict([tuple(line.split("<ref>")[0].replace("|", "").split(" = ")) for line in infobox])
コード例 #5
0
def main():
    text = mogura.get_country_text(u"イギリス", mogura.get_country())
    print "\n".join([line.strip() for line in text.split("\n") if line.startswith("[[Category:")])