19 lines
756 B
Python
19 lines
756 B
Python
import requests
|
|
import re
|
|
import bs4
|
|
|
|
x = requests.get('http://gs.xjtu.edu.cn/index.htm')
|
|
|
|
# <li>
|
|
# <span class="time fr">2023-09-12</span>
|
|
# <a class="tzgglm" href="tzgg/pygz.htm">培养工作</a>|<a class="tzggbt" href="info/1146/9867.htm" title="关于2023年下半年全国大学英语四、六级考试报名的通知"><span style="color: red; --darkreader-inline-color: #ff1a1a;" data-darkreader-inline-color="">[置顶]</span>关于2023年下半年全国大学英语四、六级考试报名的通知</a>
|
|
# </li>
|
|
|
|
# 用正则获取其中的 time
|
|
data_time = re.findall('<span class="time fr">(.*?)</span>', x.text)
|
|
|
|
|
|
# 用 bs4 获取其中的 time
|
|
soup = bs4.BeautifulSoup(x.text, 'html.parser')
|
|
data_time = soup.find_all('span', class_='time fr')
|