<tr><td width='150px'><strong>报告期</strong></td><td>2009-06-30</td><td>2009-03-31</td><td>2008-12-31</td><td>2008-09-30</td></tr><tr><td colspan='5'><strong>资产</strong></td></tr><tr><td colspan='5'><strong>流动资产</strong></td></tr><tr><td width='150px'><a target='_blank' href='/corp/view/vFD_FinanceSummaryHistory.php?stockid=600827&type=hbzj'>货币资金</a></td><td>7,107,315,888</td><td>7,461,738,198</td><td>7,102,736,371</td><td>6,074,186,310</td></tr><tr><td width='150px'><a target='_blank' href='/corp/view/vFD_FinanceSummaryHistory.php?stockid=600827&type=dqtz'>短期投资</a></td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td width='150px'><a target='_blank'
我想提取货币资金后面得7,107,315,888,不知道怎么弄,请高手指教
我想提取货币资金后面得7,107,315,888,不知道怎么弄,请高手指教
然后搜索第一个<td>,在</td>之间的数字就是你想要的。
s="网页源代码"
i = InStr(s, "货币资金")
s1 = Right(s, Len(s) - i - 16)
j = InStr(s1, "</td><td>")
s2 = Left(s1, j - 1)
t = s2
MsgBox "货币资金:" & t
i = InStr(s, "短期投资净额")
s1 = Right(s, Len(s) - i - 18)
j = InStr(s1, "</td><td>")
s2 = Left(s1, j - 1)
t = s2
MsgBox "短期投资净额:" & t
Option Explicit
Dim Page As Long
Dim Table1 As HTMLTable, Tables As IHTMLElementCollection
Dim Row As HTMLTableRow, Cell As HTMLTableCell
Dim i, j, tmp
Dim text1, text2 As StringPrivate Sub Command1_Click()
Set Tables = WebBrowser1.Document.getElementsByTagName("Table")
For Each Table1 In Tables
If Left(Table1.innerText, 2) = "币种" Then ' 找到需要的Table
' 将表格转换成“.csv”格式
For i = 1 To Table1.rows.Length - 1
Set Row = Table1.rows(i)
j = 0
For Each Cell In Row.cells
text1 = text1 + Trim(Row.cells(j).innerText) + ","
j = j + 1
Next
text1 = Left(text1, Len(text1) - 1) + vbCrLf
Next
' 数据存盘
Open "C:\Data.csv" For Append As #1
Print #1, Left(text1, Len(text1) - 2): text1 = "": Close #1
MsgBox "数据采集成功"
Exit For
End If
Next
End SubPrivate Sub Form_Load()
WebBrowser1.Navigate "http://www.icbc.com.cn/ICBCDynamicSite/Optimize/Quotation/QuotationListIframe.aspx?variety=1&publishDate=2008-12-31" ' 起始网址
End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)' 判断当前网页是否全部调入完毕
If Not (pDisp Is WebBrowser1.Object) Then Exit Sub
End Sub
再给你一个能用的截取函数 '通用截取函数Public Function strCut( strContent As String, StrStart As String, StrEnd As String) As String
Dim strHtml, s1, S2 As String
strHtml = strContent
On Error Resume Next
If InStr(strHtml, StrStart) = 0 Then
strCut = ""
Else
s1 = InStr(strHtml, StrStart) + Len(StrStart)
S2 = InStr(s1, strHtml, StrEnd)
strCut = Mid$(strHtml, s1, S2 - s1)
End If
End Function
调用SourceHtml="<tr> <td width='150px'> <strong>报告期 </strong> </td> <td>2009-06-30 </td> <td>2009-03-31 </td> <td>2008-12-31 </td> <td>2008-09-30 </td> </tr> <tr> <td colspan='5'> <strong>资产 </strong> </td> </tr> <tr> <td colspan='5'> <strong>流动资产 </strong> </td> </tr> <tr> <td width='150px'> <a target='_blank' href='/corp/view/vFD_FinanceSummaryHistory.php?stockid=600827&type=hbzj'>货币资金 </a> </td> <td>7,107,315,888 </td> <td>7,461,738,198 </td> <td>7,102,736,371 </td> <td>6,074,186,310 </td> </tr> <tr> <td width='150px'> <a target='_blank' href='/corp/view/vFD_FinanceSummaryHistory.php?stockid=600827&type=dqtz'>短期投资 </a> </td> <td>0 </td> <td>0 </td> <td>0 </td> <td>0 </td> </tr> <tr> <td width='150px'> <a target='_blank'
"
ret=strCut(SourceHtml,"货币资金 </a> </td> <td>","</td> ")像你这种格式的,还是用楼上的代码读表格来得容易一些