當前位置:編程學習大全網 - 網站源碼 - 如何用BeautifulSoup解析script中的內容

如何用BeautifulSoup解析script中的內容

關於如何用BeautifulSoup解析script中的內容:

源代碼

from?bs4?import?BeautifulSoup

html_doc?=?'''

<div?class="line-title">

<span?class="title">

<b>

111

<span?class="t-small?c-green">

(222)

</span>

</b>

</span>

<span?class="sechovershow?jzbtn?c-lined?small?marl10?act-ugc-edit?act-ugc-edit-base1"?style="margin-top:-5px">

<i?class="fa?fa-pencil">

</span>

</div>

soup?=?BeautifulSoup(html_doc,?"html.parser")

#?初級版

didi?=?soup.b.next_element.strip()

invest?=?soup.b.span.next_element.strip()

#?進階版

didi,?invest?=?soup.b.stripped_strings

  • 上一篇:股票黃金分割線怎麽畫?表示什麽意思?
  • 下一篇:如何將geoserver源代碼打包成war包,然後放在tomcat下運行
  • copyright 2024編程學習大全網