fork(1) download
  1. from bs4 import BeautifulSoup
  2.  
  3. html_doc = ("<section id=\"box3\" class=\"nodisp_zero\" style=\"display: none;\">\n"
  4. " <h1 id=\"box_ttl3\" style=\"display: none;\"></h1>\n"
  5. " <img style=\"width: 100%; display: none;\" id=\"box_img3\" alt=\"box3\" src=\"https://s...content-available-to-author-only...s.jp/s/topics/img/dummy.png\" class=\"lazy\" data-original=\"https://s...content-available-to-author-only...s.jp/s/topics/img/201808/201808220015_box_img3_A.jpg?1533975785\">\n"
  6. " <figcaption id=\"box_caption3\" style=\"display: none;\"></figcaption>\n"
  7. " <div class=\"textarea clearfix\">\n"
  8. " <h2 id=\"box_subttl3\" style=\"display: none;\"></h2>\n"
  9. " <div class=\"fontL\" id=\"box_com3\" style=\"display: none;\"></div>\n"
  10. " </div>\n"
  11. "</section>")
  12. soup = BeautifulSoup(html_doc, 'html.parser')
  13. for tag in soup.findAll(lambda tag:tag.has_attr('style')):
  14. tag["style"] = tag["style"].replace("display: none;", "")
  15.  
  16. print(str(soup))
Success #stdin #stdout 0.16s 119552KB
stdin
Standard input is empty
stdout
<section class="nodisp_zero" id="box3" style="">
<h1 id="box_ttl3" style=""></h1>
<img alt="box3" class="lazy" data-original="https://s...content-available-to-author-only...s.jp/s/topics/img/201808/201808220015_box_img3_A.jpg?1533975785" id="box_img3" src="https://s...content-available-to-author-only...s.jp/s/topics/img/dummy.png" style="width: 100%; ">
<figcaption id="box_caption3" style=""></figcaption>
<div class="textarea clearfix">
<h2 id="box_subttl3" style=""></h2>
<div class="fontL" id="box_com3" style=""></div>
</div>
</img></section>