我的脚本可以抓取的是包含
Mondays December 26th 2016 Horse Racing Tips
Mondays
2016
总是出现在每个标题中。
现在,我想抓取不同目录下的内容
喜欢
Sunshine Coast Race Tips
. 每个选项下都有多个比赛提示
星期一
.
其中一个比赛提示:
Sunshine Coast Race Tips:
Race 1: 7, 5, 4, 3 - Winner (1) $1.30 Exacta $1.90 Trifecta $4.10
Race 2: 2, 4, 3, 8 - Winner (1) $3.40 Exacta $62.70 Trifecta $116.10 First 4 $158.80
Race 3: 4, 10, 5, 13 - 2nd and 4th - Loss
这是我迄今为止的尝试:
import requests
from lxml.html import fromstring
url = "https://www.freehorseracingtipsaustralia.com/mondays-horse-racing-results-2016"
res = requests.get(url,headers={"User-Agent":"Mozilla/5.0"})
root = fromstring(res.text)
for item in root.xpath("//b[starts-with(.,'Mondays')]"):
print(item.text_content())