python - extracting text from tags in html using beautifulsoup -


This is the part of the HTML code that expresses the information that I want to remove from a webpage. Remove the name and the value between the B tags. The result I hope is such a list is: [on, DVI, 396,2035,2551]

  ... 
Power: & lt; B & gt; Current & lt; / B & gt; & Lt; Br> & Lt; Br> Source: & lt; B & gt; DVI & lt; / B & gt; & Lt; Br> & Lt; Br> Lamp runtime: & lt; B & gt; 396 & lt; / B & gt; Hours & lt; Br> Lamp Balance: & lt; B & gt; 2035 & lt; / B & gt; Hours & lt; Br> Total operation: & lt; B & gt; 2551 & lt; / B & gt; Hours & lt; Br> & Lt; / Div & gt; ...

What I tried was: import from b4 beautiful soup urllib2 url = 'IP address here' html = urllib2 Urlopen (url) .read () soup = beautiful soup (html) main_div = soup.find ("div", {"class": "txt"}) data = main_div.findAll ('b'). Text

What's wrong? FYI, I am starting one, please stand by me.

Try

  data = [main_db for bststring .findAll ('b')]    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -