Template talk:Louvre rooms

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Obtained through quick and dirty Python hack:

import re
import urllib


f = open('louvretemplated.txt', 'a')


def failed(ID):
    faileddump = open('louvrefailed.txt', 'a')
    faileddump.write(str(ID) + ", ")


for ID in range(1,900):
        title = ""
        name = ""
        location = ""
        wing = ""
        floor = ""
        unit = ""

        url = "http://cartelfr.louvre.fr/cartelfr/visite?srv=sal&idSalle=" + str(ID) 
        src = urllib.urlopen(url)
        handled = src.read()
        title = re.findall(r"<span class=\"fiche_titre_salle\">\n?.*\n?</span>", handled)

        url = "http://cartelfr.louvre.fr/cartelfr/visite?srv=sal&idSalle=" + str(ID) 
        src = urllib.urlopen(url)
        handled = src.read()
        unit = re.findall(r"<span class=\"textetitre\">.*</span>", handled)

        url = "http://cartelfr.louvre.fr/cartelfr/visite?srv=sal&idSalle=" + str(ID) 
        src = urllib.urlopen(url)
        handled = src.read()
        location = re.findall(r"<a class=\"fiche_ss_titre_salle\">.*</a>", handled)

        if len(title) == 1 and len(location) == 2 and len(unit) == 1:
            wing = location[0][32:len(location)-6]
            floor = location[1][32:34]
            name = title[0][37:title[0].find("(")]
            number = title[0][title[0].find("(")+1:title[0].find(")")]
            unit = unit[0][25:len(unit)-8]

            f.write(" |" + str(ID) + " = {{#switch: {{{query|}}}"+ "\n")
            f.write("  |name= " + name + "\n")
            f.write("  |unit= " + unit + "\n")
            f.write("  |number= " + number + "\n")
            f.write("  |wing= " + wing + "\n")
            f.write("  |floor= " + floor + "\n")
            f.write("}}\n\n")
            
        else:
            failed(ID)


print "done"



Find and replace :

  • floor = En -> floor = entresol

Start a discussion about Template:Louvre rooms

Start a discussion