亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python + Selenium Web 抓取動態元素

Python + Selenium Web 抓取動態元素

30秒到達戰場 2022-08-25 15:10:12
我正在嘗試從SEC存檔網站中提取以下信息。1)大型加速文件管理器 2)加速文件管理器 3)非加速文件管理器 4)小型報告公司 5)新興成長型公司這是它在網站上的顯示方式:Large accelerated filer     ?       Accelerated filer           ?Non-accelerated filer       ?  (Do not check if a smaller reporting company)         Smaller reporting company   ?Emerging growth company     ?在某些情況下,一個或多個項目可能不存在。我想編寫一個通用代碼,可以為許多公司提取這些值?,F在我面臨的問題是HTML的結構正在從一個公司到另一個公司發生變化。到目前為止,我已經遇到了3種不同的結構(請參閱下面的HTML結構)。如何編寫代碼以跨不同結構進行泛化?<td valign="bottom">Large&nbsp;accelerated&nbsp;filer</td><td valign="bottom">&nbsp;</td><td valign="bottom">?</td><td valign="bottom">&nbsp;&nbsp;</td><td valign="bottom">Accelerated&nbsp;filer</td><td valign="bottom">&nbsp;</td><td valign="bottom">?</td></tr><tr style="page-break-inside:avoid ; font-family:Times New Roman; font-size:10pt"><td valign="bottom"><font style="white-space:nowrap">Non-accelerated&nbsp;filer</font></td><td valign="bottom">&nbsp;</td><td valign="bottom">?&nbsp;&nbsp;(Do not check if a smaller reporting company)</td><td valign="bottom">&nbsp;&nbsp;</td><td valign="bottom">Smaller&nbsp;reporting&nbsp;company</td><td valign="bottom">&nbsp;</td><td valign="bottom">?</td></tr><tr style="page-break-inside:avoid ; font-family:Times New Roman; font-size:10pt"><td valign="bottom">Emerging&nbsp;growth&nbsp;company</td><td valign="bottom">&nbsp;</td><td valign="bottom">?</td><td valign="bottom">&nbsp;&nbsp;</td><td valign="bottom"></td><td valign="bottom">&nbsp;</td><td valign="bottom"></td></tr>另一種結構:filer&nbsp;&nbsp;<font style="FONT-FAMILY:WINGDINGS">x</font>&nbsp;&nbsp;&nbsp;&nbsp;Accelerated filer&nbsp;&nbsp;<font style="FONT-FAMILY:WINGDINGS">¨</font>&nbsp;&nbsp;&nbsp;&nbsp;Non-accelerated filer&nbsp;&nbsp;<font style="FONT-FAMILY:WINGDINGS">¨</font>&nbsp;&nbsp;&nbsp;&nbsp;Smaller reporting company&nbsp;&nbsp;<font style="FONT-FAMILY:WINGDINGS">¨</font> </font>
查看完整描述

1 回答

?
米脂

TA貢獻1836條經驗 獲得超3個贊

您可以嘗試3個XPath的組合(|運算符)來獲得您需要的東西(已勾選的項目):

//td[.="?"]/preceding::td[string-length(.)>1][1]/text()|//font[.="x"]/following::text()[1]|//font[.="t"]/preceding::text()[1]

您提供的 html 格式不正確。如果它不起作用,請提供其他內容。


查看完整回答
反對 回復 2022-08-25
  • 1 回答
  • 0 關注
  • 238 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號