以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- html 采集的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=105003) |
-- 作者:qianqian1530 -- 发布时间:2017/8/10 1:15:00 -- html 采集的问题 目前采集还可以, 但是,我还想采集 td 中的 title属性 怎么采集呢? <tr align=right><td title="#199109 ZD_XD_SELL_01--5642595">5642601</td><td class=msdate nowrap>2017.08.09 01:02:20</td><td>sell</td><td class=mspt>1.50</td><td>usdjpy</td><td style="mso-number-format:0\\.000;">110.250</td><td style="mso-number-format:0\\.000;">0.000</td><td style="mso-number-format:0\\.000;">0.000</td><td class=msdate nowrap>2017.08.09 01:05:57</td><td style="mso-number-format:0\\.000;">110.237</td><td class=mspt>0</td><td class=mspt>0</td><td class=mspt>0</td><td class=mspt>1 950</td></tr> Dim data As String = FileSys.ReadAllText("C:\\Users\\Administrator\\Desktop\\DetailedStatement.htm").Replace(vbcrlf, "").Replace(chr(9), "") Dim reg As new System.Text.RegularExpressions.Regex("(?><tr.*?>).*?</tr>") Dim reg2 As new System.Text.RegularExpressions.Regex("(?<=<td.*?>).*?(?=<)") Dim mc As object = reg.Matches(data) Dim dr As DataRow For i As Integer = 3 To mc.count - 33 Dim m As object = reg2.Matches(mc(i).value) Dim n As object = reg3.Matches(m(0).value) If m(0).value <> " " dr = DataTables("DetailedStatement").AddNew() dr("Ticket") = m(0).value dr("OpenTime") = m(2).value dr("Type") = m(4).value dr("Size") = m(6).value dr("Item") = m(8).value dr("Price") = m(10).value dr("SL") = m(12).value dr("TP") = m(14).value dr("CloseTime") = m(16).value dr("Price_c") = m(18).value dr("Commission") = n(0).value If m.count =28 dr("Taxes") = m(22).value dr("Swap") = m(24).value dr("Profit") = m(26).value End If End If Next |
-- 作者:有点甜 -- 发布时间:2017/8/10 9:36:00 -- Dim data As String = FileSys.ReadAllText("d:\\test.txt").Replace(vbcrlf, "").Replace(chr(9), "") Dim reg As new System.Text.RegularExpressions.Regex("(?><tr.*?>).*?</tr>") Dim reg2 As new System.Text.RegularExpressions.Regex("<td.*?>.*?<") Dim reg3 As new System.Text.RegularExpressions.Regex("(?<=<td.*?>).*?(?=<)") Dim reg4 As new System.Text.RegularExpressions.Regex("(?<=title="").*?(?="")") Dim mc As object = reg.Matches(data) For i as integer = 0 to mc.count-1 \'output.show(mc(i).value) Dim m As object = reg2.Matches(mc(i).value) output.show(m(0).value) Dim m1 As object = reg3.Matches(mc(i).value) output.show(m1(0).value) Dim m2 As object = reg4.Matches(mc(i).value) If m2.count > 0 Then output.show(m2(0).value) End If next |