簡體   English   中英

使用 Beautiful Soup 在 HTML 中查找方法數據綁定標簽

[英]Find Method Data-Bind tag within HTML with Beautiful Soup

我無法在 Beautiful Soup 中選擇這個“數據綁定”object,然后解析其中的數據。 此方法沒有任何數據綁定查找器,例如 class 或 id 分機。

我只需要很少的文字“2.179”。 我怎樣才能得到這個文本。

 <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,內容 2.179 在data-bind下不存在。 您可以 select span標簽然后獲取其第一個孩子的文本。

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

會給你

'2.179'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM