我试图从这一页中删除股票代码:
https://quotes.fidelity.com/mmnet/SymLookup.phtml?reqforlookup=REQUESTFORLOOKUP&productid=mmnet&isLoggedIn=mmnet&rows=50&for=stock&by=cusip&criteria=294100102&submit=Search.
在页面响应中,我看到:
<tr><td height="20" nowrap=""><font class="smallfont">ENZO BIOCHEM ORD SHS</font></td>
<td align="center" width="20%"><font><a href="/webxpress/get_quote?QUOTE_TYPE=&SID_VALUE_ID=ENZ">ENZ</a></font></td>
<td><font> </font></td>
<td><font></font></td></tr>
</tbody></table></td></tr>
我只需要打印ENZ
。在
我该如何使用BeautifulSoup实现这一点?还有,有没有更简单的方法(看起来没有API,但我可能错了)?在
以下是我目前为止的代码:
^{pr2}$
仅仅使用
font a
就可以作为css选择器。在另一种似乎相当健壮的方法是使用带有contains运算符的attribute = value选择器来瞄准}
^{pr2}$a
标记{在尝试访问
.text
之前,最好将匹配的元素设置为变量并测试None
例如
相关问题 更多 >
编程相关推荐