htmlText=''' <bookstore> <book id="b1"&...

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) print(s.extract()) for e in s: print(e.extract()) 程序结果: [<selector xpath="//book/@id" data="b1">, <selector xpath="//book/@id" data="b2">] ['b1', 'b2'] b1 b2 A、s=selector.xpath("/book/@id") B、s=selector.xpath("//book/@id") C、s=selector.xpath("//book/id") D、s=selector.xpath("/book/id")

时间:2024-04-12 15:34:17

相似题目