题目内容 (请给出正确答案)
[主观题]

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")

提问人:网友polarbear627 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“htmlText=''' <bookstore> <book…”相关的问题
第1题
BookStore数据库中有图书表Book(BookCode, BookName, Author, PublisherCode, PublishTime,BookSort, ISBN, BookPicture, ContentInro, Price, Discount),其中 PublishTime是datetime类型。 显示图书的最高价、最低价、平均价、最高价与最低价之间的差值。SQL语句: SELECT MAX(Price) As 最高价, MIN(Price) As 最低价, Str(AVG(Price),6,2) As 平均价, ________ As 最高价与最低价的差值 From Book

A、(MAX-MIN)Price

B、MAX(Price)-MIN(Price)

C、(MAX-MIN)(Price)

D、MAX:Price-MIN:Price

点击查看答案
第2题
查询Book表中的图书的类别(BookSort),要求每个类别只显示一次。语句如下: SELECT ________ BookSort FROM Book
点击查看答案
第3题

from scrapy.selector import Selector htmlText=''' <bookstore> <book id="b1"> <title lang="english">HarryPotter</title> <price>29.99</price> </book> </bookstore> ''' selector=Selector(text=htmlText) _________________________ print(s) print(s.extract()) for e in s: print(e.extract()) 程序结果: [<selector xpath="//book/title/text()" data="arry ">, <selector xpath="//book/title/text()" data="otter">] ['arry ', 'otter'] arry otter

A、s=selector.xpath("//book/title/text()")

B、s=selector.xpath("/book/title/text()")

C、s=selector.xpath("//book/title/text")

D、s=selector.xpath("/book/title/text")

点击查看答案
第4题
selector.xpath("//book[id='book1']//price")与selector.xpath("//price")结果一样;
点击查看答案
第5题
selector.xpath("//price/text()").extract()返回price下面的文本字符串
点击查看答案
第6题
from scrapy.selector import Selector htmlText="A1B...

from scrapy.selector import Selector htmlText="A1B1<c>C1</c><d>D<e>E</e></d>B2<c>C2</c>" selector=Selector(text=htmlText) s=selector.xpath("//a/preceding-sibling::*") print(s.extract()) s=selector.xpath("//b/preceding-sibling::*[position()=1]") print(s.extract()) s=selector.xpath("//b[position()=2]/preceding-sibling::*") print(s.extract()) ___________________________________________________________________ print(s.extract()) 程序结果: [] ['A1', '<d>D<e>E</e></d>'] ['A1', 'B1', '<c>C1</c>', '<d>D<e>E</e></d>'] ['<d>D<e>E</e></d>']

A、s=selector.xpath("//b[position()=1]/preceding-sibling::*[position()=2]")

B、s=selector.xpath("//b[position=1]/preceding-sibling::*[position=2]")

C、s=selector.xpath("//b[position=2]/preceding-sibling::*[position=1]")

D、s=selector.xpath("//b[position()=2]/preceding-sibling::*[position()=1]")

点击查看答案
第7题
from scrapy.selector import Selector htmlText="A1B...

from scrapy.selector import Selector htmlText="A1B1<c>C1</c><d>D<e>E</e></d>B2<c>C2</c>" selector=Selector(text=htmlText) s=selector.xpath("//a/following-sibling::*") print(s.extract()) s=selector.xpath("//a/following-sibling::*[position()=1]") print(s.extract()) s=selector.xpath("//b[position()=1]/following-sibling::*") print(s.extract()) _____________________________________________ print(s.extract()) 程序结果: ['B1', '<c>C1</c>', '<d>D<e>E</e></d>', 'B2', '<c>C2</c>'] ['B1'] ['<c>C1</c>', '<d>D<e>E</e></d>', 'B2', '<c>C2</c>'] ['<c>C1</c>']

A、s=selector.xpath("//b[position()=1]/following-sibling::*[position()=1]")

B、s=selector.xpath("//b[position()=1]/following-sibling::*")

C、s=selector.xpath("//b/following-sibling::*[position()=1]")

D、s=selector.xpath("//b/following-sibling::*")

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信