免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6578 | 回复: 2
打印 上一主题 下一主题

python 如何抽取Excel中的超链接的地址? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-04-20 10:03 |只看该作者 |倒序浏览
本帖最后由 tommydu 于 2011-04-20 10:10 编辑

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

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

论坛徽章:
0
2 [报告]
发表于 2011-04-21 13:28 |只看该作者
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:foo@bar.com?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, 下载次数: 27)

论坛徽章:
0
3 [报告]
发表于 2011-04-27 13:57 |只看该作者
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP