ema / pycodicefiscale

Python library for handling Italian fiscal code, officially known as Italy's Codice Fiscale
http://pypi.python.org/pypi/codicefiscale/
GNU Lesser General Public License v2.1
14 stars 12 forks source link

getting municipalities #4

Open ale-rt opened 10 years ago

ale-rt commented 10 years ago

Ciao Emanuele! I added a get_municipality function.

The codes are taken from agenzia delle entrate with this script:

from pyquery import PyQuery
from string import uppercase

data = []
for character in uppercase:
    html = PyQuery(
        'http://www1.agenziaentrate.it/documentazione/versamenti/codici/ricerca/VisualizzaTabella.php?iniz=%s&ArcName=COM-ICI&pRet=Tabelle.php'  # noqa
        % character
    )
    rows = html.find('#elencoTributiF24 tr')
    for row in rows:
        datum = [x.text.strip() for x in row.findall('td')]
        if datum:
            data.append(datum)