请教 VB6.0 提取上海期货交易所网页铜的数据
问题:自动从前十天铜的收盘价 结算价存入文本文件. 网页:http://www.shfe.com.cn/statements/hq_kx.html。
获取到该网页的信息:
<style>
....
....
<form action="
statement.jsp?subjectid=103002001
" method="post" name="FrmState" target="smsg">
<td BACKGROUND=/images_new/today4.gif width=692 height=90 ALIGN="RIGHT" VALIGN="middle">
<select NAME="year" CLASS="smallInput">
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option SELECTED value="2012">2012</option>
<option value="2013">2013</option>
</select>年
<select NAME="month" CLASS="smallInput">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option SELECTED value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>月
<select NAME="date" CLASS="smallInput">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option SELECTED value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>日
<input type="button" name="Submit" value="搜索" onclick="getUrlContent('103002001')">
</td>
</form>
</tr>
<tr>
<td>
<table width="692" border="0" cellspacing="0" cellpadding="0" align="center" class="mybody">
<tr width="692">
<td width="36"><img src="images_logo/spoint.jpg" width="36" height="17"> </td>
<td height="18" valign="bottom" style="letter-spacing:3px">您当前的位置:首页/交易数据/每日快讯<a href="/statements/sysm1110.html" class="news">(使用声明)</a></td>
<td height="18" valign="bottom" style="letter-spacing:3px">(<font color="#003399">当日数据需在收市结算完成后生成</font>)</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="tdid">
<iframe width="100%" height="1100" frameborder="0" id="smsg" name="smsg" src="" scrolling="auto"></iframe>
</td>
<script language="javascript">
var http_requestr = false;
var vrequesturl="/dailydata/kx/kx20120620.html";
var vframeid="smsg";
var vtdid="tdid";
var vnotestr="2012年06月20日暂无";
var vfalg=0;
var subid = "103002001";
if(subid=="103004002"||subid=="103002004"||subid=="103002003"||subid=="103003002"||subid=="103005002"){
getUrlContent(subid);
}else{
vflag="1";
checkiframe(vframeid,vrequesturl);
}
</script>
</tr>
</table>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="8"></td>
</tr>
<tr>
<td><table width="890" border="0" cellpadding="0" cellspacing="10" bgcolor="#E5E5E5">
<tr>
...
...
</SCRIPT>
图片使用之前的
[解决办法]
EXCEL Vba:
Sub 上海期货交易所期货合约行情()
Set oDoc = CreateObject("htmlfile")
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", "http://www.shfe.com.cn/dailydata/kx/kx20130815.html", True
.send
.WaitForResponse
oDoc.body.innerHTML = .responsetext
Set r = oDoc.getElementById("tableInstrument").Rows
For i = 1 To r.Length - 1
For j = 0 To r(i).Cells.Length - 1
Cells(i + 1, j + 1) = r(i).Cells(j).innerText
Next j
Next i
End With
End Sub