關於如何用BeautifulSoup解析script中的內容:
源代碼
from?bs4?import?BeautifulSouphtml_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