'how to get text from li tag and strong tag seperately? [duplicate]
how to get text from li tag and strong tag seperately using bs4 python
my code till now
from bs4 import BeautifulSoup as bs
import requests
url = "https://www.modernlibrary.com/top-100/100-best-novels/"
response = requests.get(url)
soup = bs(response.content,'lxml')
data = soup.find('div',"list-100").find('ol')
new = data.find_all('div',"row")
for i in new:
f = i.find('strong')
g = i.find('li')
print(g)
the output is <li class="alt"><strong>BRIDESHEAD REVISITED</strong> by Evelyn Waugh</li>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|