我尝试使用VBA从下面的td标记(<td><font class="s1">52.84</font>
)中获取单个单元格并将其发布到Excel工作表中。
请参阅下面的HTML剪辑:
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td bgcolor="#999999">
<table cellpadding="1" cellspacing="1" border="0" width="100%">
<tbody>
<tr bgcolor="#cccccc" align="right" height="20">
<td><font class="s1">Price</font></td>
<td><font class="s1">Change (%)</font><img src="/design/images/0.gif" width="4" height="1" border="0/"></td>
<td><font class="s1">52 wk High</font><img src="/design/images/0.gif" width="4" height="1" border="0/"></td>
<td><font class="s1">52 wk Low</font><img src="/design/images/0.gif" width="4" height="1" border="0/"></td>
<td><font class="s1">Stock volume </font><a href="javascript:openHelp(14)" alt="Open Help"><img src="/design/images/ico/q_zn.gif" width="8" height="10" border="0" alt="Open Help"></a><img src="/design/images/0.gif" width="4" height="1" border="0/"></td>
<td><font class="s1">1WK Avg Opt Volume</font><a href="javascript:openHelp('avg_1wk_ov')" alt="Open Help"><img src="/design/images/ico/q_zn.gif" width="8" height="10" border="0" alt="Open Help"></a><img src="/design/images/0.gif" width="3" height="1" border="0/"></td>
<td><font class="s1">1WK Avg Opt OI</font><a href="javascript:openHelp('avg_1wk_oi')" alt="Open Help"><img src="/design/images/ico/q_zn.gif" width="8" height="10" border="0" alt="Open Help"></a><img src="/design/images/0.gif" width="3" height="1" border="0/"></td>
<td><font class="s1">EOD Opt Volume</font><a href="javascript:openHelp('eod_ov')" alt="Open Help"><img src="/design/images/ico/q_zn.gif" width="8" height="10" border="0" alt="Open Help"></a><img src="/design/images/0.gif" width="3" height="1" border="0/"></td>
<td><font class="s1">EOD Opt OI</font><a href="javascript:openHelp('eod_oi')" alt="Open Help"><img src="/design/images/ico/q_zn.gif" width="8" height="10" border="0" alt="Open Help"></a><img src="/design/images/0.gif" width="3" height="1" border="0/"></td>
</tr>
<tr bgcolor="#FFFFFF" align="right" height="20"> ***
<td><font class="s1">52.84</font>*** </td>
<td><font class="s1"><nobr> <img src="/design/images/ico/arrow_bottom.gif" alt="-" border="0" align="absmiddle" width="7" height="9/"> -1.06 (-1.97%)</nobr></font></td>
<td><font class="s1"><nobr> 60.34 07/22/2015</nobr></font></td>
<td><font class="s1"><nobr> 46.95 01/30/2015</nobr></font></td>
<td><font size="-2" class="s1">17,092,380</font></td>
<td><font size="-2" class="s1">87,610</font></td>
<td><font size="-2" class="s1">1,820,400</font></td>
<td><font size="-2" class="s1">54,450</font></td>
<td><font size="-2" class="s1">1,858,857</font></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
答案 0 :(得分:0)
由于您没有发布网址,这只是猜测。 。 。
Sub Test() Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "http://www.marketwatch.com/investing/stock/aapl/analystestimates" ' should work for any URL
Do Until .ReadyState = 4: DoEvents: Loop
x = .document.body.innertext
y = InStr(1, x, "Average Target Price:")
Z = Mid(x, y, 6)
Range("A1").Value = Trim(Z)
.Quit
End With
End Sub