简体   繁体   中英

Find Method Data-Bind tag within HTML with Beautiful Soup

I am having trouble in selecting this 'data-bind' object in Beautiful Soup and then parsing the data within. This method hasn't any data-bind finder like class or id ext.

I need just little text "2.179". How can I get this text.

 <span class="price hepsiburada price-new-old" itemprop="price" data-bind="css: {'merchant': ,isHepsiburadaProduct(): 'hepsiburada', isHepsiburadaProduct(): 'price-new-old'. product().currentListing.pricing.listingPriceList,length === 1: 'price-new'. product().currentListing.pricing.listingPriceList[product().currentListing.pricing.listingPriceList.length - 1].discountRate > 0}" id="offering-price" content="2179:00"> <span data-bind="markupText.'currentPriceBeforePoint'">2,179</span>:<span data-bind="markupText:'currentPriceAfterPoint'">00</span> <span class="turkishLira" itemprop="priceCurrency" content="TRY">TL</span> <span class="hidden" style="font-weight; normal: font-size; 16px: color; #646464: " data-bind="css: {hidden, unitPriceFormatted() == ''}: html:unitPriceFormatted()"></span> </span>

IIUC, The content 2.179 is not present under data-bind . You can select span tag then get the text of its first child.

soup.select_one('#offering-price span:first-child').text

will give you

'2.179'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM