(Jun-30-2021, 04:51 PM)snippsat Wrote: I would do like this also remove<br>
tag so it's clean and it's better to write CSS for new line.
Could also to this in a parser eg BeautifulSoup,but adding like simple whiteout.
with open(r'test.html') as f, open('out.html', 'w') as f_out: for line in f: line = line.replace('<br>', '') #print(f'<input type="checkbox"> {line}') f_out.write(f'<input type="checkbox"> {line}')Example with CSS CodePen
Output:<input type="checkbox"> <a href="https://www.google.com">Link </a> <input type="checkbox"> <a href="https://www.youtube.com">Link </a> <input type="checkbox"> <a href="https://www.instagram.com">Link </a>
Maybe also add a<ul>
Tag for better CSS.
why I run will occur
UnicodeDecodeError: 'cp950' codec can't decode byte 0xbf in position 2: illegal multibyte sequence
I try to add
with open(r'test.html',encoding="utf-8") as f, open('out123.html', 'w',encoding="utf-8") as f_out: for line in f: print(line) line = line.replace('<br>', '') print(f'<input type="checkbox"> {line}') f_out.write(f'<input type="checkbox"> {line}')but the output look like this:
it still not add checkbox in front of the link, only the first one.
<input type="checkbox"> <a href="https://www.google.com">Link </a><a href="https://www.youtube.com">Link </a><a href="https://www.instagram.com">Link </a>Thanks