back-end/threats_monitoring/ransomware.py
def crawl_ransomware_lists(html_code):
    """ Scrapes all the need data from the downloaded web page
        @parameter
            html    (str)   html source code (never None) of downloaded page
        @retukrn
            values  (list)  list with all scraped values
    """

    soup = BeautifulSoup(html_code, 'lxml')

    second_table_rows = soup.find_all('table')[1]
    td_elements = second_table_rows.find_all('td')
    block_lists = list([])

    for i in range(0, len(td_elements), 6):

        try:
            relative_link = td_elements[i+5].a.get('href')
            absolute_link = 'https://ransomwaretracker.abuse.ch' + relative_link
        except Exception:
            print("No link assigned for this list. Skip it")
            continue

        row_dict = {
            # row_list.append(td_elements[i].string)
            "Malware-Type": td_elements[i + 1].string,
            "Scope": td_elements[i + 2].string,
            "Blocklist-Type": [word for word in td_elements[i + 3].string.split(' ') if word in ['URL', 'Domain', 'IP']][0],
            "FP-Risk": td_elements[i + 4].string,
            "link": absolute_link
        }
        block_lists.append(row_dict)

    return block_lists

    # ---------------------------------------------------------------------------------------------------------------- #

 Scrapes all the need data from the downloaded web page
        @parameter
            html    (str)   html source code (never None) of downloaded page
        @retukrn
            values  (list)  list with all scraped values
    
Scrapes all the need data from the downloaded web page
@parameter
html    (str)   html source code (never None) of downloaded page
@retukrn
values  (list)  list with all scraped values
Scrapes all the need data from the downloaded web page @parameter html ( str ) html source code ( never None ) of downloaded page @retukrn values ( list ) list with all scraped values
def crawl_ransomware_lists(html_code):
    soup = BeautifulSoup(html_code, 'lxml')
    second_table_rows = soup.find_all('table')[1]
    td_elements = second_table_rows.find_all('td')
    block_lists = list([])
    for i in range(0, len(td_elements), 6):
        try:
            relative_link = td_elements[i+5].a.get('href')
            absolute_link = 'https://ransomwaretracker.abuse.ch' + relative_link
        except Exception:
            print("No link assigned for this list. Skip it")
            continue
        row_dict = {
            "Malware-Type": td_elements[i + 1].string,
            "Scope": td_elements[i + 2].string,
            "Blocklist-Type": [word for word in td_elements[i + 3].string.split(' ') if word in ['URL', 'Domain', 'IP']][0],
            "FP-Risk": td_elements[i + 4].string,
            "link": absolute_link
        }
        block_lists.append(row_dict)
    return block_lists
def crawl_ransomware_lists ( html_code ) : soup = BeautifulSoup ( html_code , 'lxml' ) second_table_rows = soup . find_all ( 'table' ) [ 1 ] td_elements = second_table_rows . find_all ( 'td' ) block_lists = list ( [ ] ) for i in range ( 0 , len ( td_elements ) , 6 ) : try : relative_link = td_elements [ i + 5 ] . a . get ( 'href' ) absolute_link = 'https://ransomwaretracker.abuse.ch' + relative_link except Exception : print ( "No link assigned for this list. Skip it" ) continue row_dict = { "Malware-Type" : td_elements [ i + 1 ] . string , "Scope" : td_elements [ i + 2 ] . string , "Blocklist-Type" : [ word for word in td_elements [ i + 3 ] . string . split ( ' ' ) if word in [ 'URL' , 'Domain' , 'IP' ] ] [ 0 ] , "FP-Risk" : td_elements [ i + 4 ] . string , "link" : absolute_link } block_lists . append ( row_dict ) return block_lists
Scrapes all the need data from the downloaded web page
@parameter
html    (str)   html source code (never None) of downloaded page
@retukrn
values  (list)  list with all scraped values
Scrapes all the need data from the downloaded web page @parameter html ( str ) html source code ( never None ) of downloaded page @retukrn values ( list ) list with all scraped values
""" Scrapes all the need data from the downloaded web page
        @parameter
            html    (str)   html source code (never None) of downloaded page
        @retukrn
            values  (list)  list with all scraped values
    """ # row_list.append(td_elements[i].string)
 # ---------------------------------------------------------------------------------------------------------------- #

html_code