# -*- coding: utf-8 -*-
from lxml.html import parse
from urllib.request import urlopen
import pandas as pd
# 可能爬的这个网页比较特殊,需要写下面两句话
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
# 根据链接获得整个html放到doc中
parsed = parse(urlopen('https://info.zufe.edu.cn/xygk/szdw.htm'))
doc = parsed.getroot()
#读取html中的table
# 用列表来存老师名字
all_teachers=[]
# 用字典保存主页链接
link_dic={}
# 用字典保存职称
zhicheng={}
# 找到html中有
的所有table,以列表的形式返回给tablestables = doc.findall('.//table')
# 我们要的是第一个table
content=tables[0].text_content()
tds = tables[0].findall('.//td')
# 一条条遍历所有td里的内容
for td in tds:
# 判断当前属于哪个职称,再给zc赋值
zhi=td.findall('.//strong')
i