如何使用<p>从ID为mydiv的div中的第二个DOMDocument标记获取内容?
例如,我的HTML看起来可能如下:
<div class='mydiv'>
<p><img src='xx.jpg'></p>
<p>i need here</p>
<p>lorem ipsum lorem ipsum</p>
</div>
我试图提取以下文本:
i need here
我该怎么做呢?
我或多或少有这个结构,如何在title之后选择下一个元素?起点必须是x或y,因为结构有重复的类等等,而且这个锚是唯一的锚。为了澄清,我需要抓住内容和引用是标题。
x = wd.find_elements_by_class_name('title')[0] // print title 0
y = wd.find_elements_by_class_name('title')[1] // print title 1
HTML:
<div class='global'>
<div class="main"&g
我有以下标签
<div class="example">
<p> text <a href="#"> link </a> text</p>
</div>
我想要得到
<p> text <a href="#"> link </a> text</p>
所以div中的所有内容都包含在类example中。我正在使用
from lxml import html
page = requests.get('X')
tr
是否有方法获取Selenium web元素的标记的名称?
我发现,在selenium中有.getTagName(),在中也有。
在这个HTML中,如果我通过类=‘some_name’进行迭代,我如何获得tag_name (h2、p、ul或li)?
<div class='some_class_name'>
<h2>Some Random Heading 1</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industr
我有一个以下HTML格式的网页。这只是一个示例和部分代码。
<div id="content">
........... Many other tags go in here......
<div id="1234"> // This id number is not constant and so cant hard code in xpath
<img class="float-right ng-scope" width="85" data-ng-click=
我在中描述了相反的问题。我不能让文本超过一层深度。
HTML的结构如下:
<span class="data">
<p>This text is extracted just fine.</p>
<p>And so is this.</p>
<p>
And this.
<div>
<p>But this text is not extracted.&
下面是一些HTML示例
<div class="something">
<p> This is a <b> Paragraph </b> with <a href="/something"> mixed </a> elements
<p> Next paragraph....
</div>
我尝试的是
//div[contains('@class','something')/text()
和
//div[contains('