You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB

import re
import requests
url_first = 'https://www.jxxdxy.edu.cn/news-list-xiaoyuanyaowen'
url_last = '.html'
urls = []
urls.append(url_first + url_last)
for i in range(2, 21):
urls.append(url_first + '-'+str(i) + url_last)
# for url in urls:
# print(url)
a = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrom/124.0.0.0 Safari/537.36 Edg/124.0.0.0'
}
# res = requests.get(urls[0], headers=a)
# res.encoding = 'utf-8'
# print(res.text)
# for url in urls:
# response = requests.get(url, headers=a)
# print(response.status_code)
# print(response.encoding)
lists = []
for url in urls:
response = requests.get(url, headers=a)
lists.append(response.text)
bd_re = '<li><a href="(.*?)" title="(.*?)".*?fr timee">(.*?)</span>'
abc = []
for text in lists:
result = re.findall(bd_re, text, re.S)
abc.append(result)
print(result)
print(len(result))
# str = '产教融合'
# for text in abc:
# for i in text:
# if str in i[1]:
# print(i)
# time = '2024-03'
# for text in abc:
# for i in text:
# if time in i[2]:
# print(i)