import pymysql
import requests as re
from bs4 import BeautifulSoup
try:
for i in range(1,389):#389
url="http://by.cuc.edu.cn/zcyw/"+str(i)
r=re.get(url)
#print(r.text)
soup = BeautifulSoup(r.text,'html.parser')
title=soup.find_all('h3',attrs={'class','tit'})
print(i)
for t in title:
newsurl=t.find_all('a')
urllen=str(newsurl[0]).find('target')
print(str(newsurl[0])[9:urllen-2])
print(t.get_text())
except:
print("error")
网友评论