import requests
from bs4 import BeautifulSoup
import re
url = 'https://tw.appledaily.com/new/realtime'
res = requests.get(url)
soup = BeautifulSoup(res.text,'lxml')
tags = soup.find('ul',attrs={'class':'rtddd slvl'})
titles = tags.find_all('h1')
for title in titles:
print(title.text)
我爬苹果日报标题
title.text 会将文字 <span>数字</span> 合并
但我只想要文字部分 数字不要
请问如何提取呢
感谢