我正在尝试从旅游网站收集定价数据。
以下是HTML,我想检索号码2145.66并将其放入Excel单元格中。
<ul class="hotelresults">
<li class="image"><img src="http://images.libertytravel.com/shared/cpl/fcl/images/upload/suppliers/H/AUA/REM/img_148208_MEDIUM.jpg" width="120" onerror="this.src='/images/book.libertytravel.com/no-pic.gif';"></li>
<li class="detail">
<h4>Renaissance Marina Hotel <img src="http://static0.traveltek.net/images/book.libertytravel.com/1star.png" alt="Star"><img src="http://static0.traveltek.net/images/book.libertytravel.com/1star.png" alt="Star"><img src="http://static0.traveltek.net/images/book.libertytravel.com/1star.png" alt="Star"><img src="http://static0.traveltek.net/images/book.libertytravel.com/1star.png" alt="Star"></h4>
<span class="myTime"></span><span class="hotelPref"></span>
<h5>Aruba</h5>
<span id="desc_555_0.1">Experience a fresh twist on stay and play in a stylish, sophisticated atmosphere at the Renaissance Aruba Resort and Casino. </span><a href="/fusion/searchsinglehotel.pl?sessionkey=F5AFD4B1-782Cl4A8B-9B26-AC8EAE88C1E5&chosenhotel=555_0.1&chosenflight=617_0.0">See Details</a>
</li>
<li class="price">
<script language="Javascript">
Event.observe(window, "load", function() {
$$('span.roomprice').each(function(element) {
element.innerHTML = properrounding(element.innerHTML, 2);
});
});
</script>
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="roomsrow">
<tr class="hide">
<td colspan="3" class="sectionHeader">
<a href="#" onclick="showmore('hotelDetails'); return false">
<div id="hotelExpand">
<div class="plusMinus"></div>
</div> Show/Hide extra room selections
</a>
</td>
</tr>
<tr>
<td colspan="3" style="border:none">
<div id="hotelDetails" style="display:none">
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="hide">
<th align="left">Room Description</th>
<th align="right">Total Basket Cost</th>
<th> </th>
</tr>
<tr>
<td colspan="3">
<script language="Javascript">
Event.observe(window, "load", function() {
$('rightprice_div_555_0.1_555:0').innerHTML = properrounding('2145.66', 2);
我的代码如下:
r = 0
c = 0
Set TDelements2 = .document.getelementsbyclassname("price")
l = TDelements2.Length
For i = 0 To l
MsgBox (TDelements2.Item(i).innertext)
MsgBox (i)
i = i + 0
Sheet2.Range("A1").Offset(r, c).Value = TDelements2.Item(i).innertext
r = r + 1
c = c + 0
Next
然而,这并没有返回我正在寻找的费率/数字。
任何帮助/建议表示赞赏。
答案 0 :(得分:0)
您可以解析该字符串的document.body.innerHTML
。假设您使用properrounding
定位感兴趣的部分。
仅使用HTML作为指南,
Debug.Print Replace(Split(Split(.document.body.innerHTML, " properrounding(")(2), ", 2")(0), Chr$(39), vbNullString)