def import_netscape_bookmarks(bookmarks_file, is_bookmark_format):
 import bs4
 with open(bookmarks_file, encoding='utf-8') as f:
  soup = bs4.BeautifulSoup(f, 'html.parser')
 html_tags = soup.findAll('a')
 if is_bookmark_format:
  output_template = '{tag[href]} {tag.string}'
 else:
  output_template = '{tag.string} {tag[href]}'
 bookmarks = []
 for tag in html_tags:
  if (tag['href'] not in bookmarks):
   bookmarks.append(output_template.format(tag=tag))
 for bookmark in bookmarks:
  print bookmark

def import_netscape_bookmarks ( bookmarks_file , is_bookmark_format ) : import bs4 with open ( bookmarks_file , encoding = 'utf-8' ) as f : soup = bs4 . BeautifulSoup ( f , 'html.parser' ) html_tags = soup . findAll ( 'a' ) if is_bookmark_format : output_template = '{tag[href]} {tag.string}' else : output_template = '{tag.string} {tag[href]}' bookmarks = [ ] for tag in html_tags : if ( tag [ 'href' ] not in bookmarks ) : bookmarks . append ( output_template . format ( tag = tag ) ) for bookmark in bookmarks : print bookmark
import bookmarks from a netscape-bookmark-file v1 .