python - finding all Strong tags with beautifulsoup returns an empty array -
i want extract strings included in strong tags , save them in file. cannot extract strong tags; returns empty array. missing anything. here code have used: input:
>>>import requests >>>from bs4 import beautifulsoup >>>r=requests.get(' http://www.webmd.com/heart-disease/heart-disease-glossary#1') >>>r.content >>> soup=beautifulsoup(r.content,"lxml") >>>print(soup) >>>soup.find_all('strong')
output last statement:
[]
thanks,
actually, there isn't strong tag in soup.
when open url in browser, can 2 strong tags. don't think need them.
<li xmlns="http://www.w3.org/1999/xhtml">check address typing errors such <strong>ww</strong>.example.com instead of <strong>www</strong>.example.com</li>
if mean terms in bold, should use .find_all('b').
[tag.text.strip().replace(':',"") tag in soup.find_all('b')]
outputs:
['ablation','advance directive (living will)','aerobic exercise', ...]
Comments
Post a Comment