网址:http://www.cn357.com/notice/
直接上代码。
#coding=utf-8
import re
import requests
def getHtml(url):
try:
page = requests.get(url)
html = page.text
return html
except:
print ("网页访问异常")
return ""
def getInfo(html):
reg = re.compile(r".*?公告批次:(.*?),生产企业:.*?识别代号:(.*?),轴数:.*?发动机排量:(.*?),发动机功率:",re.S)
items = re.findall(reg,html)
for item in items:
print("\t".join(list(map(str.strip,item))))
if __name__=='__main__':
for i in range(1,61):
url = "http://www.cn357.com/cvi.php?m=cvinotice&search=n&brand=%B1%F0%BF%CB&page=" + str(i)
html = getHtml(url)
getInfo(html)