+ -
当前位置:首页 → 问答吧 → python 如何抽取Excel中的超链接的地址?

python 如何抽取Excel中的超链接的地址?

时间:2011-04-20

来源:互联网

本帖最后由 tommydu 于 2011-04-20 10:10 编辑

请教大家个问题:python 如何抽取Excel中的超链接的地址?

这里http://www.numbergrinder.com/200 ... -using-python-xlrd/ 说python-xlrd不支持这个需求?
有什么办法吗?谢谢!

作者: tommydu   发布时间: 2011-04-20

SVN URL:   https://secure.simplistix.co.uk/svn/xlrd/trunk
revision: 4774 ***CHANGED*** (bug fix needed)
Installation: cd to your checkout directory and do /wherever/it/is/python setup.py install
sample xls file: attached
sample interactive session:

    >>> import xlrd
    >>> b = xlrd.open_workbook('hlink_example.xls')
    >>> s = b.sheet_by_index(0)
    >>> len(s.hyperlink_list)
    9
    >>> for h in s.hyperlink_list:
    ...     h.dump(header = 60 * '-')
    ...
    ------------------------------------------------------------
    desc: u'example description (e-mail)'
    fcolx: 1
    frowx: 1
    lcolx: 1
    lrowx: 1
    type: u'url'
    url_or_path: u'mailto:[email protected]?subject=xlrd%20better%20than%20sliced%20bread%20and%20WD40'
    ------------------------------------------------------------
    desc: u'python.org website'
    fcolx: 1
    frowx: 2
    lcolx: 1
    lrowx: 2
    type: u'url'
    url_or_path: u'http://www.python.org/'
    ------------------------------------------------------------
    desc: u'top left cell in 2nd sheet'
    fcolx: 1
    frowx: 3
    lcolx: 1
    lrowx: 3
    textmark: u'Sheet2!A1'
    type: u'workbook'
    ------------------------------------------------------------
    desc: u'sample local file'
    fcolx: 1
    frowx: 4
    lcolx: 1
    lrowx: 4
    type: u'local file'
    url_or_path: 'dummy.txt'
    ------------------------------------------------------------
    desc: u'desc of UNC file'
    fcolx: 1
    frowx: 5
    lcolx: 1
    lrowx: 5
    type: u'unc'
    url_or_path: u'\\\\MACHINENAME\\c:\\xlrd\\hyperlinks\\dummy.txt'
    ------------------------------------------------------------
    desc: u'struct format parameters'
    fcolx: 1
    frowx: 6
    lcolx: 1
    lrowx: 6
    textmark: u'format-characters'
    type: u'url'
    url_or_path: u'http://docs.python.org/library/struct.html'
    ------------------------------------------------------------
    desc: u'4th char of name is U+00E4'
    fcolx: 1
    frowx: 7
    lcolx: 1
    lrowx: 7
    type: u'local file'
    url_or_path: u'fub\xe4r.txt'
    ------------------------------------------------------------
    desc: u'Sheet3!A1:Z99'
    fcolx: 1
    frowx: 8
    lcolx: 1
    lrowx: 8
    textmark: u'Sheet3!A1:Z99'
    type: u'workbook'
    ------------------------------------------------------------
    desc: u'http://www.foo.com'
    fcolx: 1
    frowx: 9
    lcolx: 1
    lrowx: 9
    type: u'url'
    url_or_path: u'http://www.foo.com/' hlink_example.zip (2.71 KB)
sample
下载次数: 0
2011-04-21 13:27

作者: tommydu   发布时间: 2011-04-21