当前位置: 首页 > 知识库问答 >
问题:

使用xpath或css查询从span检索文本

艾才良
2023-03-14

我需要从以下span元素中检索文本,而不需要将其拆分为文本部分。

<span class="a-size-base review-text">I purchased this from Fry's Electronics.
<br/>
<br/>
The picture is quite good after tweaking the settings.  An HDMI feed from my PC results in very clear text with no distortion.  Be sure to turn down the sharpness to avoid artifacts around text.  I think this screen may offer 4:4:4 chroma subsampling based on the attached test image.  I'm very pleased with the viewing angles and the screen is definitely usable for more than just straight ahead viewing.
<br/>
<br/>
I wasn't planning on using the Smart features, but the Netflix app works really well and is responsive enough to not become annoyed.  The wifi streaming playback is very smooth, but navigating the folder structure is horribly slow.  The interface insists on creating thumbnails for each movie file, which takes forever if you have a directory with many files.  I would much rather just see a detailed list without thumbnails.  When you finally do find your desired movie the playback is very good.  If you keep the directory contents small (~10 items or fewer) you may not have any problems.
<br/>
<br/>
The unit is very thin and light and setup was a breeze.  You just have to put in 4 screws to attach the base and then you're ready to go.  The power adapter comes with a "brick" style converter.  The remote is well laid out and the menus are easy to navigate without feeling cumbersome.
<br/>
<br/>
The stand is 8" deep x 22.25" wide.  The TV stands 26.5" from table top to the top of the bezel with stand attached.  The TV is 42.75" wide from outside bezel edge to outside bezel edge.
<br/>
<br/>
Overall I'm very pleased with what this offers in the $400-500 range.  (I actually paid $398 but that was after some customer service adjustments at Fry's).
<br/>
<br/>
NOTE: If you see any strange distortion in the images it's likely a result of the camera, image compression, and resizing.  Some of the strange patterns seen in the images are not present when viewing in person.
</span>
Text='I purchased this from Fry's Electronics.'
Text=''
Text='The picture is quite good after tweaking the settings.  An HDMI feed from my PC results in very clear text with no distortion.  Be sure to turn down the sharpness to avoid artifacts around text.  I think this screen may offer 4:4:4 chroma subsampling based on the attached test image.  I'm very pleased with the viewing angles and the screen is definitely usable for more than just straight ahead viewing.'
Text=''
Text='I wasn't planning on using the Smart features, but the Netflix app works really well and is responsive enough to not become annoyed.  The wifi streaming playback is very smooth, but navigating the folder structure is horribly slow.  The interface insists on creating thumbnails for each movie file, which takes forever if you have a directory with many files.  I would much rather just see a detailed list without thumbnails.  When you finally do find your desired movie the playback is very good.  If you keep the directory contents small (~10 items or fewer) you may not have any problems.'
Text=''
Text='The unit is very thin and light and setup was a breeze.  You just have to put in 4 screws to attach the base and then you're ready to go.  The power adapter comes with a "brick" style converter.  The remote is well laid out and the menus are easy to navigate without feeling cumbersome.'
Text=''
Text='The stand is 8" deep x 22.25" wide.  The TV stands 26.5" from table top to the top of the bezel with stand attached.  The TV is 42.75" wide from outside bezel edge to outside bezel edge.'
Text=''
Text='Overall I'm very pleased with what this offers in the $400-500 range.  (I actually paid $398 but that was after some customer service adjustments at Fry's).'
Text=''
Text='NOTE: If you see any strange distortion in the images it's likely a result of the camera, image compression, and resizing.  Some of the strange patterns seen in the images are not present when viewing in person.'

我想检索一个没有破损的文本块。我正在使用这个xpath测试器http://www.freeformatter.com/xpath-tester.html

共有1个答案

穆招
2023-03-14

将整个元素转换为字符串:

string(
  //*[contains(concat( " ", @class, " a-size-base review-text" ), concat( " ", "review-text", " " ))]
)

请注意,这只适用于第一个与条件匹配的元素。在XPath2.0中,可以使用string-join(),它可以处理任意数量的元素:

string-join(   
    //*[contains(concat( " ", @class, " a-size-base review-text" ), concat( " ", "review-text", " " ))]/text(),
    ""
)
 类似资料:
  • 在curl请求中,我有一个html表,其结构如下所示。现在,我只想提取包含带有空类的span元素的表行,而不是包含class=“subcomponent”的表行。我成功地尝试了Xpath来查找带有空类的元素,但是如何获取整个,甚至是包含Version和partnumber的特定节点。提前谢了。 我的PHP代码

  • 上面的XPath查询捕获了我正在查看的特定部分中的所有文本,这很棒。但是,我只需要知道testuser是否在那个部分。

  • 我正在尝试使用查询检索dynamodb表中的所有项。下面是我的代码: 但是,我收到以下错误: 我的代码非常简单,出自boto dynamodb2文档,因此我不确定为什么会出现上述错误。任何见解都将受到赞赏(这是新的,有点迷失)。谢谢 编辑:我有一个散列键和一个范围键。我能够通过特定的哈希键进行查询。例如 但我如何检索所有项目?

  • 我在下面的网页中找不到链接的XPath/CSS选择器:“Select Participant”,然后我将循环遍历所有链接。 列表链接=driver.findElements(By.xpath(“//div[contains(@class='glossymenu')]//a”);迭代器iter=links.Iterator();//system.out.println(“CLASS Elements

  • 问题内容: 我正在使用SQL Server,但没有足够的数据集来测试查询的性能。 我想分析查询,看看索引是否被利用。我该如何检查 问题答案: 在SQL Management Studio中,只需键入查询,然后按Control-L(显示查询执行计划)。在那里,您将能够查看是否正在使用任何索引。“表扫描”表示未使用索引。“索引扫描”是指使用索引。

  • 我想使用querybuilder从搜索路径中排除子节点路径 例如,父文件夹是/content/mysite/en 子文件夹是 /content/mysite/en/testfolder1 /content/mysite/en/testfolder2 我希望查询生成器编写一个查询来排除这些路径 我已经考虑过这个问题了- AEM查询生成器排除搜索中的文件夹 但是分组路径和p.not=true似乎并不像