Exemplo n.º 1
0
def forum(sezione):
    response = urlopen("http://forum.informatica.unict.it/")
    html_doc = response.read()
    s = BeautifulSoup(html_doc, 'html.parser')
    s.prettify()
    dictionary = {}
    for range_limit, main_table in enumerate(s.findAll("div", class_="tborder")):
        if(range_limit >= 3):  # If che limita le sezioni a quelle interessate, evitando di stampare sottosezioni come "News" della categoria "Software"
            break
        for td_of_table in main_table.findAll("td", class_="windowbg3"):
            for span_under in td_of_table.findAll("span", class_="smalltext"):
                for anchor_tags in span_under.find_all('a'):
                    anchor_tags_splitted = anchor_tags.string.split(",")
                    anchor_tags_without_cfu = StringParser.remove_cfu(anchor_tags_splitted[0])

                    if(sezione == anchor_tags_without_cfu.lower()):
                        dictionary[anchor_tags_without_cfu.lower()] = anchor_tags['href']
                        return dictionary

    return False  # Redefine with @Veeenz API