您的位置:程序门 -> vb -> 网络编程



vb如何获取span之间的内容


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vb如何获取span之间的内容
发表于:2007-10-02 03:40:50 楼主
<span   id="cashaccount"> 10.00 </span>
<span   id="donationaccount"> 96.40 </span>
<span   id="withdrawaccount"> 2.12 </span>
网页内容如上
但是我用webbrowser控件如何获取10.00这个内容呢?
我写的代码如下:
dim   vdoc,   vtag
dim   i   as   integer
set   vdoc   =   webbrowser1.document
for   i   =   0   to   vdoc.all.length   -   1   '检测所有标签
        if   ucase(vdoc.all(i).tagname)   =   "span"   then             '找到input标签
                  set   vtag   =   vdoc.all(i)
                if   ucase(vtag.id)   =   "cashaccount"   then
                    text1.text   =   vtag.value
                end   if
        end   if
next
但用   vtag.value   好象不对,请问大家有什么办法吗?
发表于:2007-10-03 00:38:421楼 得分:0
可考虑使用正则表达式
发表于:2007-10-14 15:38:032楼 得分:0
理论上应该是对的   是不是cashaccount   出现了两次以上啊  
可以用split   先把网页源代码获取下来   然后用
dim   a()   as   string
a()=split(htmltext," <span   id=""cashaccount""   > ")
a()=split(a(1)," </span   > ")
text1.text=a(0)
这样就ok了
发表于:2007-10-14 17:45:383楼 得分:0
vbscript code
dim vdoc, vtag dim i as integer set vdoc = webbrowser1.document for i = 0 to vdoc.all.length - 1 '检测所有标签 if ucase(vdoc.all(i).tagname) = "span" then '找到input标签 set vtag = vdoc.all(i) if ucase(vtag.id) = "cashaccount" then text1.text = vtag.innertext end if end if next


快速检索

最新资讯
热门点击