from scrapy.selector import Selector htmlText=''' ...
from scrapy.selector import Selector htmlText=''' <bookstore> <book id="b1"> <title lang="english">Harry Potter</title> <price> 29.99 </price> </book> <book id="b2"> <title lang="chinese">学习XML</title> <price> 39.95 </price> </book> </bookstore> ''' selector=Selector(text=htmlText) ____________________________________ print(s.extract_first()) ____________________________________ print(s.extract_first()) 程序结果: <title lang="english">Harry Potter</title> <title lang="chinese">学习XML</title>
A、s=selector.xpath("//book[position=1]/title"); s=selector.xpath("//book[position=2]/title")
B、s=selector.xpath("//book[position()=2]/title"); s=selector.xpath("//book[position()=1]/title")
C、s=selector.xpath("//book[position=2]/title"); s=selector.xpath("//book[position=1]/title")
D、s=selector.xpath("//book[position()=1]/title"); s=selector.xpath("//book[position()=2]/title")