推荐学习书目
› 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
godluo
V2EX  ›  Python

scrapy 如何爬取网页元素显示样式设置为不可见(即 style="display:none")标签下的内容

  •  
  •   godluo · Oct 28, 2018 · 4826 views
    This topic created in 2891 days ago, the information mentioned may be changed or developed.
    如题,scrapy 新手请教,如何爬取网页元素显示样式设置为不可见(即 style="display:none")标签下的内容:
    网页源码如下:
    <dl class="xxx" style="display:none">
    <li>
    <span class="fl">text1</span>
    <p class="fl">text11</p>
    </li>
    <li>
    <span class="fl">text2</span>
    <p class="fl">text22</p>
    </li>
    </dl>

    请教如何操作?谢谢!
    6 replies  •  2018-10-29 17:18:08 +08:00
    Trim21
        1
    Trim21  
       Oct 29, 2018 via Android
    元素 display:none 会导致 xpath 选不到吗?
    thedog
        2
    thedog  
       Oct 29, 2018 via Android
    不可见,源码里还是有的,有什么影响吗?
    NLL
        3
    NLL  
       Oct 29, 2018
    一样可以 xpath 取到的
    xpresslink
        4
    xpresslink  
       Oct 29, 2018
    不可见样式是指浏览器渲染方式不让人眼见,然而你爬虫取到的是网页的字符串。
    Qzier
        5
    Qzier  
       Oct 29, 2018 via iPhone
    有什么区别吗?
    godluo
        6
    godluo  
    OP
       Oct 29, 2018 via Android
    scrapy shell ,元素 display:none 会导致 xpath 选不到。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3034 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 11:14 · PVG 19:14 · LAX 04:14 · JFK 07:14
    ♥ Do have faith in what you're doing.