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])
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("[[ファイル:")])
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])
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])
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:")])