Foxtable(狐表)用户栏目专家坐堂 → [求助]网页取值(又有新问题,见8楼)


  共有2881人关注过本帖树形打印复制链接

主题:[求助]网页取值(又有新问题,见8楼)

帅哥,在线噢!
有点蓝
  11楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/19 14:01:00 [只看该作者]

调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm

查询到的所有网页标签都判断一下,比如:
Dim tb1 As object = web.Document.GetElementsByTagName("table")(3) 这种如果网页没有第4个table,肯定就出错,判断一下
If tb1.count > 3

 回到顶部
帅哥哟,离线,有人找我吗?
yyzlxc
  12楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1525 积分:10580 威望:0 精华:0 注册:2008/9/24 11:16:00
  发帖心情 Post By:2020/3/20 12:47:00 [只看该作者]

根据老师的提示,写了一段代码进行判断,但是出现错误提示,错在哪里?还请老师指教,谢谢!!

Dim web As New System.Windows.Forms.WebBrowser()
web.ScriptErrorsSuppressed = True
For Each dr As DataRow In DataTables("表A").Select("","简码")
    If dr.IsNull("简码") = False Then
        web.Navigate("https://vip.stock.finance.sina.com.cn/corp/go.php/vCI_CorpOtherInfo/stockid/" & dr("简码") & "/menu_num/2.phtml")
        Do Until web.ReadyState = 4
            Application.DoEvents
        Loop
        Dim tb1 As object = web.Document.GetElementsByTagName("table")(3)
        If tb1.count > 3
            MessageBox.Show("出错1")
        End If
        Dim tb2 As object = web.Document.GetElementsByTagName("table")(4)
        If tb2.count > 4
            MessageBox.Show("出错2")
        End If
        Dim wz As Integer = Tables("表A").FindRow(dr)
        If wz >= 0 Then
            Tables("表A").Position = wz
        End If
    End If
Next


---------------------------
版本:2020.1.19.19
---------------------------
代码执行出错,错误信息:

System.MissingMemberException: 未找到类型“HtmlElement”的公共成员“count”。

   在 Microsoft.VisualBasic.CompilerServices.Symbols.Container.GetMembers(String& MemberName, Boolean ReportErrors)

   在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)

   在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)

   在 UserCode.Test()
---------------------------
确定   
---------------------------

 回到顶部
帅哥,在线噢!
有点蓝
  13楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/20 14:29:00 [只看该作者]

        Dim tb1 As object = web.Document.GetElementsByTagName("table")
        If tb1.count <= 3
            MessageBox.Show("出错1")
        End If

 回到顶部
总数 13 上一页 1 2