Getting the URL from Excel Sheet Hyper links in Python with xlrd

大城市里の小女人 提交于 2019-12-24 00:57:08

问题


I am trying to get the hyperlinks URL of elements in the 2nd column of an Excel sheet using xlrd. When using:

book = open_workbook('mypath', formatting_info=True)
sheet = book.sheet_by_index(0)
r_sheet = book.sheet_by_index(0)
wb = copy(book)
w_sheet = wb.get_sheet(0)

for row_index in range(1, sheet.nrows):    
    URL = sheet.hyperlink_map.get((row_index, 1))
    print URL 

I get:

<xlrd.sheet.Hyperlink object at 0x0000000002D81898>
<xlrd.sheet.Hyperlink object at 0x0000000002D819E8>
<xlrd.sheet.Hyperlink object at 0x0000000002D81DA0>

What do I have to add to my code to get URL formatted in a string format and not an xlrd.sheet.Hyperlink object so they can be later used in the code? I am looking to get the actual URL that I see when highlighting the elements of the first column in Excel, so something like http://www.mywebpage.com

来源:https://stackoverflow.com/questions/26566983/getting-the-url-from-excel-sheet-hyper-links-in-python-with-xlrd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!