Exemplo n.º 1
0
def forum(sezione):

    response = urllib2.urlopen("http://forum.informatica.unict.it/")
    html_doc = response.read()

    #print(html_doc)
    s = BeautifulSoup(html_doc, 'html.parser')
    s.prettify()
    dictionary = {}
    for rangeLimit, mainTable in enumerate(s.findAll("div", class_="tborder")):
        if (
                rangeLimit >= 3
        ):  #If che limita le sezioni a quelle interessate, evitando di stampare sottosezioni come "News" della categoria "Software"
            break
        for tdOfTable in mainTable.findAll("td", class_="windowbg3"):
            for spanUnder in tdOfTable.findAll("span", class_="smalltext"):
                for anchorTags in spanUnder.find_all('a'):
                    anchorTagsSplitted = anchorTags.string.split(",")
                    anchorTagsWithoutCFU = StringParser.removeCFU(
                        anchorTagsSplitted[0])

                    if (sezione == anchorTagsWithoutCFU.lower()):
                        dictionary[
                            anchorTagsWithoutCFU.lower()] = anchorTags['href']
                        return dictionary

    return False  #Redefine with @Veeenz API
Exemplo n.º 2
0
def forum(sezione):

    response = urllib2.urlopen("http://forum.informatica.unict.it/")
    html_doc = response.read()

    # print(html_doc)
    s = BeautifulSoup(html_doc, "html.parser")
    s.prettify()
    dictionary = {}
    for rangeLimit, mainTable in enumerate(s.findAll("div", class_="tborder")):
        if (
            rangeLimit >= 3
        ):  # If che limita le sezioni a quelle interessate, evitando di stampare sottosezioni come "News" della categoria "Software"
            break
        for tdOfTable in mainTable.findAll("td", class_="windowbg3"):
            for spanUnder in tdOfTable.findAll("span", class_="smalltext"):
                for anchorTags in spanUnder.find_all("a"):
                    anchorTagsSplitted = anchorTags.string.split(",")
                    anchorTagsWithoutCFU = StringParser.removeCFU(anchorTagsSplitted[0])

                    if sezione == anchorTagsWithoutCFU.lower():
                        dictionary[anchorTagsWithoutCFU.lower()] = anchorTags["href"]
                        return dictionary

    return False
Exemplo n.º 3
0
def forum_cmd(text):
    text = text.replace("/forum ", "")
    dict_url_sezioni = forum(text)
    if not (dict_url_sezioni == False):
        for titoli in dict_url_sezioni:
            output = StringParser.starts_with_upper(titoli) + ": " + str(dict_url_sezioni[titoli])
    else:
        output = "La sezione non e' stata trovata."
    return output
Exemplo n.º 4
0
def forum_cmd(text):
    text = text.replace("/forum ", "")
    dictUrlSezioni = forum(text)
    if not (dictUrlSezioni == False):
        for titoli in dictUrlSezioni:
            output = StringParser.startsWithUpper(titoli) + ": " + str(dictUrlSezioni[titoli])
    else:
        output = "La sezione non e' stata trovata."
    return output