推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
aragakiiyui
V2EX  ›  Python

关于 xpath 的问题

  •  
  •   aragakiiyui · May 21, 2015 · 3040 views
    This topic created in 4154 days ago, the information mentioned may be changed or developed.
    请问如何使用xpath语法实现只提取p标签中的内容,而不要em标签的内容。

    <p class="">哈哈哈
    <em class="">嘻嘻嘻</em>
    </p>
    5 replies  •  2015-05-21 18:26:17 +08:00
    ericls
        1
    ericls  
       May 21, 2015
    先对 node 进行操作,删除 em 这个 element 再提取文字?
    kingname
        2
    kingname  
       May 21, 2015   ❤️ 1
    xxx.xpath('//p/text()')[0]
    jsq2627
        3
    jsq2627  
    PRO
       May 21, 2015   ❤️ 1
    aragakiiyui
        4
    aragakiiyui  
    OP
       May 21, 2015
    @ericls 这个方法我知道,可是有没有直接提取出来的方法?
    aragakiiyui
        5
    aragakiiyui  
    OP
       May 21, 2015
    @kingname ....这样显然不行啊...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2412 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:26 · PVG 22:26 · LAX 07:26 · JFK 10:26
    ♥ Do have faith in what you're doing.