zoukankan      html  css  js  c++  java
  • pyquery CSS基本选择器

    html = '''
    <div id="container">
    <div id="www">
        <ul class="list">
             <li class="item-0">first item</li>
             <li class="item-1"><a href="link2.html">second item</a></li>
             <li class="item-0 active"><a href="link3.html"><span class="bold">third item</span></a></li>
             <li class="item-1 active"><a href="link4.html">fourth item</a></li>
             <li class="item-0"><a href="link5.html">fifth item</a></li>
         </ul>
         </div>
     </div>
    '''
    from pyquery import PyQuery as pq
    doc = pq(html)
    print(doc('#container .list li'))
    
    print(doc('#www .list li'))#两个输出结果一致
    '''
    输出结果:<li class="item-0">first item</li>
             <li class="item-1"><a href="link2.html">second item</a></li>
             <li class="item-0 active"><a href="link3.html"><span class="bold">third item</span></a></li>
             <li class="item-1 active"><a href="link4.html">fourth item</a></li>
             <li class="item-0"><a href="link5.html">fifth item</a></li>
    
    '''
  • 相关阅读:
    多进程 与并发
    socket之 udp用法 dns 多道 进程
    粘包
    socket tcp
    数据集特点
    secureCRT
    算法
    auto-encoder小记
    pytorch dataloader num_workers
    CNN试验记录
  • 原文地址:https://www.cnblogs.com/liangliangzz/p/10272705.html
Copyright © 2011-2022 走看看