html是這樣的:
<a rel="nofollow" class="external text" href="Mylink.com"><font color="#547794"><u>My link Title</u></font></a>
我能夠提取“a”標簽,但如何提取“a”標簽內的標題“我的鏈接標題”?
soup = BeautifulSoup(page, 'html.parser')
for link in soup.find_all('a', href=True):
link_str = str(link['href'])
print(link_str)
uj5u.com熱心網友回復:
這是一個作業示例
from bs4 import BeautifulSoup
html = '<a rel="nofollow" href="Mylink.com"><font color="#547794"><u>My link Title</u></font></a>'
soup = BeautifulSoup(html.encode(), 'html.parser').find('u').text
print(soup)
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/378046.html
