作者:
nini200 (200妮妮)
2018-12-25 23:29:20import 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> 合併
但我只想要文字部分 數字不要
請問如何提取呢
感謝