css selector
来始终获得第一个 <small>
:
soup.select('tr > td:first-of-type > small:first-of-type')
要根据您的示例获取所有标题,请使用
list comprhension
:
[title.get_text(strip=True).split(' ')[-1] for title in soup.select('tr > td:first-of-type > small:first-of-type')]
结果:
['EFURIX CREM 15 GR S VALEA', 'ASDRON XPE FR 100ML', 'DIAD 0,75MGC/ 2 COMP']