第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

從 edgar 中抓取特定數(shù)據(jù)

從 edgar 中抓取特定數(shù)據(jù)

紅顏莎娜 2023-09-12 17:34:08
有一段HTML代碼<tr bgcolor="#cceeff" style="page-break-inside:avoid ; font-family:Def.-Times; font-size:8pt"><td colspan="3" valign="top"> <p style=" margin-top:0pt ; margin-bottom:0pt; margin-left:2.00em; text-indent:-1.00em; font-size:8pt; font-family:ARIAL"><b>{99}</b> <b></b>Receivables becoming Defaulted Receivables during period</p></td><td align="right" valign="bottom"><font style="font-family:ARIAL; ">1,310,326.05</font></td> <td nowrap="nowrap" valign="bottom"><font style="font-family:ARIAL; "> </font></td> <td valign="bottom"> </td> <td valign="bottom"></td> <td valign="bottom"></td>我怎樣才能提取數(shù)據(jù){4}Defaulted Receivables', '{4}', '1,310,326.05']我有一個(gè)人給我的代碼def get_row(soup, n):    return [td.get_text(strip=True) for td in soup.select('tr:contains("{' + str(n) + '}") td') if td.get_text(strip=True)]但首先,我不明白如何在 HTML 代碼中查找“行”。其次, tr:contains("{' + str(n) + '}") td這段代碼是做什么的?抱歉,我對(duì)抓取和 HTML 還很陌生
查看完整描述

1 回答

?
慕尼黑的夜晚無繁華

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超6個(gè)贊

我改進(jìn)/更正了代碼,現(xiàn)在它將打印每行的條目文本列表列表。

代碼需要一次安裝 beautiful soup 和 lxml:python -m pip install lxml bs4。

在線嘗試一下!

# Needs: python -m pip install lxml bs4

import lxml

from bs4 import BeautifulSoup


soup = BeautifulSoup("""

<tr bgcolor="#cceeff" style="page-break-inside:avoid ; font-family:Def.-Times; font-size:8pt">

<td colspan="3" valign="top"> <p style=" margin-top:0pt ; margin-bottom:0pt; margin-left:2.00em; text-indent:-1.00em; font-size:8pt; font-family:ARIAL"><b>{99}</b> <b></b>Receivables becoming Defaulted Receivables during period</p></td>

<td align="right" valign="bottom"><font style="font-family:ARIAL; ">1,310,326.05</font></td>

 <td nowrap="nowrap" valign="bottom"><font style="font-family:ARIAL; "> </font></td>

 <td valign="bottom"> </td>

 <td valign="bottom"></td>

 <td valign="bottom"></td>

</tr>

""", 'lxml')


print([[

    td.get_text(strip=True) for td in tr.select('td') if td.get_text(strip=True)

] for tr in soup.select('tr')])

代碼打?。?/p>


[['{99}Receivables becoming Defaulted Receivables during period', '1,310,326.05']]


查看完整回答
反對(duì) 回復(fù) 2023-09-12
  • 1 回答
  • 0 關(guān)注
  • 120 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)