Files
football-data/football_game.py
2026-01-14 17:19:21 +08:00

31 lines
797 B
Python

import requests
from lxml import etree
# 只能搜索左边的队伍
key = '伊普斯维奇'
url = f'https://www.zhibo8.com/schedule/finish_more.htm'
myheader = {'user-agent': 'Chrome'}
response = requests.get(url, headers=myheader)
response.encoding = 'utf-8'
html = response.content
element = etree.HTML(html)
# 搜索定位(取第一个)
span_elements = element.xpath('//li/span[@class="_teams"]')
for span in span_elements:
team = span.text
# print(team)
if key in team:
break
a_elements = span.xpath('../a')
for a in a_elements:
url_jijin = a.get('href')
url_luxiang = 'https://www.zhibo8.com' + \
url_jijin.replace('jijin', 'luxiang')
print(url_jijin)
print(url_luxiang)
# https://www.zhibo8.com/zuqiu/2024/1030-match1448348v-luxiang.htm