我正在使用htmlunit来获取网页数据。我想用<div class>
获取数据。但我无法找到班级找到的方法。我如何获取数据?
以下是网页来源:
<div class="content-detail">
<ul class="detail-list limited-detail">
<li>
<div class="content-sub-title">2GoGoGo Limited </div>
<div class="info-list">
<span>Tel:</span>
<p>+111 1111 2222</p>
</div>
<div class="info-list">
<span>Fax:</span>
<p>+111 1111 3333</p>
</div>
<div class="info-list">
<span>E-mail</span>
<p><a href="mailto:elaine.lee@2gotrade.com">gogogo@2gogogo.com</a></p>
</div>
<div class="info-list">
<span>Company website</span>
<p><a href="http://www.gogogo.com" target="_blank">http://www.2gotrade.com</a></p>
</div>
<div class="info-list">
<span>Address</span>
<p>Company address</p>
</div>
<div class="info- list">
<span>Introduction</span>
<p> We are.... </p>
</div>
</li>
</ul>
</div>
如何在源上获取公司详细信息?非常感谢。
答案 0 :(得分:0)
我们可以如下使用功能 getByXPath 。
getByXPath("//div[@class='class1 class2']");
在上面的示例中,
'//' indicates to search direct and indirect element
'div' indicates that my element is type of div
'@class' indicates attribute name, we can use @id, @name etc.
'class1 class2' we need to pass all class names here, only 'class1' doesn't work
here