Search code examples
pythonsplinter

Python splinter select by tag attribute


I am messing around with some web scraping using Splinter but have this issue. The html basically has loads of li only some of which I am interested in. The ones I am interested in have a bid value. Now, I know for Beautiful Soup I can do

tab = browser.find_by_css('li', {'bid': '18663145091'})

but this doesn't seem to work for splinter. I get an error saying:

find_by_css() takes exactly 2 arguments (3 given)

This is a sample of my html:

<li class="rugby" bid="18663145091">
          <span class="info">
           <div class="points">
            12
           </div>
           <img alt="Leinster" height="19" src="..Leinster" width="26"/>
          </span>
</li>

Solution

  • It looks like you are using find_by_css() method as if it was a BeautifulSoup method. Instead, provide a valid CSS selector checking the value of the bid attribute:

    tab = browser.find_by_css('li[bid=18663145091]')