Beautiful Soup

From ElectroDragon
Jump to navigation Jump to search

属性

案例 marketwatch =》 https://www.marketwatch.com/investing/stock/aapl

  • 查找属性 = print(soup.find_all(field='last'))
<bg-quote class="ignore-color negative" field="last" format="0,0.00" channel="/zigman2/quotes/211618636/realtime" data-last-stamp="1567363673000" data-last-raw="3075.54">3,075.54</bg-quote>
  • second
print(soup.find_all(channel="/zigman2/quotes/202934861/composite,/zigman2/quotes/202934861/lastsale")[1].string)