Given the HTML code below, I want to output only h1 text, but not "Details about", which is the span text (which is enclosed in h1).
My current output gives:
Details about New Men Genuine Leather Bifold ID Credit Card Money Holder Wallet Black
I would like to:
New Men Genuine Leather Bifold ID Credit Card Money Holder Wallet Black
Here is the HTML I'm working with
<h1 class="it-ttl" itemprop="name" id="itemTitle"><span class="g-hdn">Details about </span>New Men's Genuine Leather Bifold ID Credit Card Money Holder Wallet Black</h1>
Here is my current code:
for line in soup.find_all('h1',attrs={'itemprop':'name'}): print line.get_text()
Note. I donβt want to just trim the string because I would like this code to have some reuse. What would be best is some kind of code that displays any text limited to a range.
source share