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

76 lines
1.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"from lxml import etree\n",
"\n",
"key='AC米兰'\n",
"\n",
"url = f'https://www.zhibo8.com/schedule/finish_more.htm'\n",
"myheader = {'user-agent': 'Chrome'}\n",
"response = requests.get(url, headers=myheader)\n",
"# response.encoding = 'utf-8'\n",
"html = response.content\n",
"element = etree.HTML(html)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://news.zhibo8.com/zuqiu/2024-10-30/match1448348date2024vnative.htm\n"
]
}
],
"source": [
"span_elements = element.xpath('//li/span[@class=\"_teams\"]')\n",
"for span in span_elements:\n",
" team=span.text\n",
" # print(team)\n",
" if key in team:\n",
" # print(team)\n",
" url_jijin=span.xpath('../a')[-1].get('href')\n",
" print(url_jijin)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}