提问者:小点点

特定于Python的web刮擦


所以我有了这个HTML,我只想把ID打印出来。 所以我想像这样打印ID:0001380185645500000001 0001380185645500000002等等。 我怎么能那么做?

null

<div class="b-find-in-store js-find-in-store" data-cmp="findInStoreModal" data-product-id="00013801856455" data-store-availability-info='[{"ID":"0001380185645500000001","isAvailableInStore":true,"isAvailableOnline":true},{"ID":"0001380185645500000002","isAvailableInStore":true,"isAvailableOnline":true},{"ID":"0001380185645500000004","isAvailableInStore":true,"isAvailableOnline":true},{"ID":"0001380185645500000005","isAvailableInStore":true,"isAvailableOnline":false},{"ID":"0001380185645500000006","isAvailableInStore":true,"isAvailableOnline":true},{"ID":"0001380185645500000007","isAvailableInStore":true,"isAvailableOnline":false},{"ID":"0001380185645500000008","isAvailableInStore":true,"isAvailableOnline":false}]' data-target-url="/on/demandware.store/Sites-snse-DE-AT-Site/de_DE/FindInStore-ShowInModal">
 <button aria-label="Im Store suchen" class="f-additional-actions-btn b-find-in-store-label">
  <span class="i-stores">
  </span>
  Im Store suchen
 </button>
</div>

null


共1个答案

匿名用户

你可以把它转换成字符串,然后再做一些类似的事情

>>>str = str(result)
>>> [s for s in str.split('"') if s.isdigit()]

['00013801856455', '0001380185645500000001', '0001380185645500000002',      
'0001380185645500000004', '0001380185645500000005', '0001380185645500000006', 
'0001380185645500000007', '0001380185645500000008']