scrapy Selector用法及xpath语法
准备工作 html示例: <?xml version="1.0" encoding="UTF-8"?> <html <head> <title>text</title> </head> <body> <div class="cdiv"> <p class="cp1 section">test p1 <span>next p1</span></p> <ul> <li id="0">1</li> <li id="1">2</li> <li id="2">3</li> </ul> </div> <div class="cdiv1"> <p class="cp2">test p2 <span>next p2</span></p> <ul> <li id="3">4</li> <li id="4">5</li> <li id="5">6</li> </ul> </div> <p class="item">test in p </p> <li id="6" class="item cli-1">7</li> <li id="7" class="item cli-2">8</li> </body> </html> 把该示例保存到test.html中. 创建python文件,输入代码 from scrapy.selector import Selector doc = '' with open('