python如何提取excel表格中的超链接

发布时间 2023-12-08 08:29:47作者: 冰底熊
import xlrd

def get_wb(path):
    wb = xlrd.open_workbook(path)
    return wb
def get_wb(path):
    wb = xlrd.open_workbook(path)
    return wb
def get_hyperlink(wb,sheet_name,cell):
    worksheet = wb.sheet_by_name(sheet_name)
    hyperlink = worksheet.hyperlink_map.get(cell)
    cell = worksheet.cell(cell[0],cell[1])
    hyperlink=hyperlink.url_or_path
    name=cell.value
    item={name:hyperlink}
    # print(item)
    return item


if __name__ == '__main__':
    path = "F:\整体.xls"
    sheet_name = "员工资质信息"
    wb = get_wb(path)
    for i in range(1,3833):
        # 获取18列的超链接
        cell=(i,18)
        link = get_hyperlink(wb,sheet_name,cell)
        print(cell,link)