Python Forum
reading html and edit chekcbox to html
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reading html and edit chekcbox to html
#4
(Jul-01-2021, 04:11 AM)jacklee26 Wrote: t still not add checkbox in front of the link, only the first one.
Ok i thought that your input was on new line,see now that input is one big line.
If you make this file could probably fix it when save it,and also save it as utf-8.

Then it will like this.
with open(r'test.html', encoding='utf-8') as f, open('out.html', 'w', encoding='utf-8') as f_out:
    content = f.read().split('<br>')
    for line in content[:-1]:
        #print(f'<input type="checkbox"> {line}')
        f_out.write(f'<input type="checkbox"> {line}\n')
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>
With <ul> tag as i talked about.
with open(r'test.html', encoding='utf-8') as f, open('out.html', 'w', encoding='utf-8') as f_out:
    content = f.read().split('<br>')
    f_out.write(f'<ul id="links">\n')
    for line in content[:-1]:
        f_out.write(f'<input type="checkbox"> {line}\n')
    f_out.write(f'</ul>\n')
CSS CodePen
Reply


Messages In This Thread
RE: reading html and edit chekcbox to html - by snippsat - Jul-01-2021, 08:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  WebElements of an HTML page Nik1811 2 401 Mar-14-2024, 12:39 PM
Last Post: Nik1811
  Going through HTML table with selenium emont 3 843 Sep-30-2023, 02:13 AM
Last Post: emont
  Need to replace a string with a file (HTML file) tester_V 1 796 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  why doesn't it replace all html tags? Melcu54 3 782 Jul-05-2023, 04:47 AM
Last Post: Melcu54
  pyscript index error while calling input from html form pyscript_dude 2 1,012 May-21-2023, 08:17 AM
Last Post: snippsat
  html module in python 3.6.8 suifra 9 1,689 May-12-2023, 11:30 AM
Last Post: suifra
  How to display <IPython.core.display.HTML object>? pythopen 3 46,100 May-06-2023, 08:14 AM
Last Post: pramod08728
  Embedding python script into html via pyscript pyscript_dude 7 1,614 Apr-16-2023, 11:17 PM
Last Post: pyscript_dude
  Tkinterweb (Browser Module) Appending/Adding Additional HTML to a HTML Table Row AaronCatolico1 0 959 Dec-25-2022, 06:28 PM
Last Post: AaronCatolico1
  BeautifulSoup - I can't translate html tags that contain <a href=..</a> OR <em></em> Melcu54 10 1,672 Oct-27-2022, 08:58 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020