请看我的笨方法把我害成什么样了
我搞网页数据截取,用了最笨的循环字符查找,到了最后,字符越来越大,速度慢的惊人。
- VB code
Private Sub Command1_Click()Dim uk1 As Stringuk1 = "ENG PR"'----------------------------------------------------------------Dim code As StringDim pickscode As StringDim keyword As Stringpickscode = "http://data.nowgoal.com/1x2/company.aspx?id=281&company=Bet 365"code = getHtmlStr$(pickscode)Dim start, startkey, over, overkeystartkey = "Compare"start = InStr(1, code, startkey, 1)overkey = "Back to Top"over = InStr(2000, code, overkey, 1)Dim xDim a, b, c, d, e, f, g, h, y, j, k For x = start To over a = Left(code, x) a = Right(a, 1) b = Left(code, x + 1) b = Right(b, 1) c = Left(code, x + 2) c = Right(c, 1) d = Left(code, x + 3) d = Right(d, 1) e = Left(code, x + 4) e = Right(e, 1) f = Left(code, x + 5) f = Right(f, 1) g = Left(code, x + 6) g = Right(g, 1) h = Left(code, x + 7) h = Right(h, 1) y = Left(code, x + 8) y = Right(y, 1) j = Left(code, x + 9) j = Right(j, 1) k = Left(code, x + 10) k = Right(k, 1) '找到联赛名 Dim league As String If a + b + c = "e31" Then Dim overl, lstr For overl = x + 2 To x + 20 lstr = Left(code, overl) lstr = Right(lstr, 1) If lstr = "<" Then league = Left(code, overl - 1) league = Right(league, overl - 1 - (x + 4)) Text1(1) = league Exit For End If Next overl End If DoEvents Text2 = Format(x / over, "##.#######") Next x
我的思路是把code 分解开来,弄成几个code,但是中间分隔不均就会造成数据丢失,请问有没有什么好办法呢,因为这个支付超过20万个。。。。。
汗。。。
[解决办法]
a = Left(code, x)
a = Right(a, 1)
不就是a=mid(code,x,1)嘛,弄这么多left,right也不嫌敲好多键盘..
'找到联赛名
之后的代码没有看见用变量d,e,f,g...k,不知道你定义,操作他们干什么用.
看你的代码就是找到"e31"的位置p,然后从p后的"<"(p后2-20位置)取若干字符...
这样大可以用正则表达式来做