def handleTd(trItem):
for index, tdItem in enumerate(trItem.select("td")):
if index in colIndex:
continue
if index == 7:
fo.writelines('| '+ '[详情](https://yz.chsi.com.cn'+tdItem.select('a')[0].attrs['href']+')' )
fo.writelines(' |\n')
continue
value = tdItem.string if tdItem.string!=None else ' '
fo.writelines(' | '+value)
def mAIn():
cities = requests.post('https://yz.chsi.com.cn/zsml/pages/getSs.jsp')
for city in json.loads(cities.text):
fo.writelines('# '+ city['mc']+'\n' )
getSchool(city['dm'])
if __name__=="__main__":
main()
fo.close()生成的清单是markdown语法,文件在d盘,打开粘贴到markdown编辑器(https://markdowneditor.cn/)进行预览,效果超级好!实例如下: