Need to isolate an element

27 views
Skip to first unread message

Sven CAILTEUX

unread,
Apr 17, 2015, 7:35:34 AM4/17/15
to beauti...@googlegroups.com
HTML CODE :
<li id="mycard-2" class="businessCard">
      <span class="number">2</span><!--  -->
        <div class="visitCardContent">
    <h2 class="titleMain">
   <a href="http://myurlsite.com" class="companyName"><span>The New Company</span>
                        &nbsp;
                        <span class="buttonMoreDetails">+&nbsp;details</span>
                    </a></h2>
        </div>
</li>

I'm a newbie with beautifulsoup, so sorry in advance for my question.
 
I would like to isolate "The New Company" and only this, actually I got this :
"The New Company
+details"

with this code
print item.find_all("a", {"class": "companyName"})[0].text

I've tried a lot of things without success

Thx in advance :) 

Sven CAILTEUX

unread,
Apr 17, 2015, 9:57:56 AM4/17/15
to beauti...@googlegroups.com
Found :-)

print item.find_all("a", {"class": "companyName"})[0].span.text
Reply all
Reply to author
Forward
0 new messages