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

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

暂无答案
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“from scrapy.selector import Se…”相关的问题

第1题

from scrapy.selector import Selector htmlText=''' ...

from scrapy.selector import Selector htmlText=''' <html> <body> <bookstore> <title>books</title> <book> <title>Novel</title> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book> <title>TextBook</title> <title lang="eng">Learning XML</title> <price>39.95</price> </book> ''' selector=Selector(text=htmlText) _____________________________________ for e in s: print(e) 程序结果: <selector xpath="//book/title" data="&lt;title&gt;Novel&lt;/title&gt;"> <selector xpath="//book/title" data="&lt;title lang=" eng">Harry Potter</selector></selector></bookstore></body></html></title>"> <selector xpath="//book/title" data="&lt;title&gt;TextBook&lt;/title&gt;"> <selector xpath="//book/title" data="&lt;title lang=" eng">Learning XML</selector></selector></book></bookstore></body></html></title>">

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

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

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

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

点击查看答案

第2题

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

点击查看答案

第3题

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) print(s.extract()) for e in s: print(e.extract()) 程序结果: [ <selector xpath="//book/title/text()" data="Harry Potter"> , <selector xpath="//book/title/text()" data="学习XML"> ] ['Harry Potter', '学习XML'] Harry Potter 学习XML

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题

from scrapy.selector import Selector htmlText=''' ...

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

点击查看答案

第5题

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()) s=selector.xpath("//book[@id='b1']/title") print(s.extract_first()) 程序结果: 学习XML <title lang="english">Harry Potter</title>

A、s=selector.xpath("//book/title[@lang='chinese']/text")

B、s=selector.xpath("//book/title[lang='chinese']/text")

C、s=selector.xpath("//book/title[@lang='chinese']/text()")

D、s=selector.xpath("//book/title[@lang='chinese']/text")

点击查看答案

第6题

from scrapy.selector import Selector htmlText=''' ...

from scrapy.selector import Selector htmlText=''' <html> <body> <bookstore> <book> <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></body></html></price></title></book></book></book></book></book></book></bookstore> ''' selector=Selector(text=htmlText) ______________________________________________ print(s.extract()) 程序结果: ['<book id="b2">\n <title lang="chinese">学习XML</title>\n <price>39.95</price>\n</book>']

A、s=selector.xpath("//title[@lang='chinese']/parent:*")

B、s=selector.xpath("//title[lang='chinese']/parent::*")

C、s=selector.xpath("//title[@lang='chinese']/parent::*")

D、s=selector.xpath("//title[lang='chinese']/parent:*")

点击查看答案

第7题

from scrapy.selector import Selector htmlText=''' ...

from scrapy.selector import Selector htmlText=''' <bookstore> <book> <title lang="eng">Harry Potter</title> <price> 29.99 </price> </book> <book> <title lang="eng">Learning XML</title> <price> 39.95 </price> </book> </bookstore> ''' selector=Selector(text=htmlText) print(type(selector)); print(selector) _______________ print(type(s)) print(s) 查找所有的 <title>

A、s=selector.xpath("title")

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

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

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

参考答案:<span style="color:rgb(255, 0, 0)">B</span>

4、from scrapy.selector import Selector htmlText=''' <html> <body> <bookstore> <title>books</title> <book> <title>Novel</title> <title lang="eng">Harry Potter</title> <price> 29.99 </price> </book> <book> <title>TextBook</title> <title lang="eng">Learning XML</title> <price> 39.95 </price> </book> ''' selector=Selector(text=htmlText) _____________________________________ for e in s: print(e) 程序结果: <selector xpath="//book/title" data="&lt;title&gt;Novel&lt;/title&gt;"> <selector xpath="//book/title" data="&lt;title lang=" eng">Harry Potter"> <selector xpath="//book/title" data="&lt;title&gt;TextBook&lt;/title&gt;"> <selector xpath="//book/title" data="&lt;title lang=" eng">Learning XML">

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

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

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

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

点击查看答案

第8题

from scrapy.selector import Selector htmlText=''' ...

from scrapy.selector import Selector htmlText=''' <bookstore> <book> <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()) 程序结果: [' <book id="b2"> \n <title lang="chinese">学习XML</title>\n <price> 39.95 </price>\n </book>']

A、s=selector.xpath("//title[@lang='chinese']/parent:*")

B、s=selector.xpath("//title[lang='chinese']/parent::*")

C、s=selector.xpath("//title[@lang='chinese']/parent::*")

D、s=selector.xpath("//title[lang='chinese']/parent:*")

点击查看答案

第9题

from scrapy.selector import Selector htmlText=''' ...

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

点击查看答案

第10题

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) s=selector.xpath("//book/price") print(type(s),s) ____________________________________ print(type(s),s) s=selector.xpath("//book/price").extract_first() print(type(s),s) 程序结果: <class 'scrapy.selector.unified.selectorlist'> [ <selector xpath="//book/price" data="&lt;price&gt;29.99&lt;/price&gt;"> , <selector xpath="//book/price" data="&lt;price&gt;39.95&lt;/price&gt;"> ] <class 'list'> [' <price> 29.99 </price>', ' <price> 39.95 </price>'] <class 'str'> <price> 29.99 </price>

A、s=selector.xpath("/book/price").extract()

B、s=selector.xpath("/book//price").extract()

C、s=selector.xpath("//book//price").extract()

D、s=selector.xpath("//book/price").extract()

点击查看答案
热门考试 全部 >
相关试卷 全部 >
账号:
你好,尊敬的上学吧用户
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
谢谢您的反馈

您认为本题答案有误,我们将认真、仔细核查,
如果您知道正确答案,欢迎您来纠错

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

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

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