Exemple #1
0
               generated content
                      """ % sys.argv[0]
                sys.exit(1)
            elif opt == '-o':
                output = arg
    except GetoptError:
        print "Wrong parameters. type  %s -h for usage" % sys.argv[0]
        sys.exit(2)

    # Richiesta del file con l'elenco insegnanti
    print "Reading people..."
    names = URLopener().open("%s://%s/%s/docenti.htm" % (URL_PROTOCOL, URL_DOMAIN, URL_SUBPATH))

    # foreach insegnante
    courses = []
    for line in names.readlines():
        key = re.sub("\<\/?[a-zA-Z]+([ a-zA-Z]+\=\"[\S]*\")*\>|\n", "", line)
        value = re.match("(.*)href\=\"(?P<url>[\S]*)\"(.*)", line).group('url')

        # richiedi la pagina insegnante
        print "Retrieve %s..." % value
        course = URLopener().open("%s://%s/%s/%s" % (URL_PROTOCOL, URL_DOMAIN, URL_SUBPATH, value))
        parser = TTParser(key)
        #   parsing orario, corso
        parser.feed(course.read())
        courses.extend(parser.get_list())

    #   inserimento in current.gap
    print "Generation complete. Writing on %s..." % output
    out = file(output, 'w')
    for c in courses:
def get_facilities(file):
    o = URLopener().open(file)
    t = o.readlines()
    o.close()
    return [i.split(' ')[0].lower() for i in t]