0

嘿,我在这里使用此代码:

'WebBrowser1.Navigate("http://0000.org/icampus")

'Do Until Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete
'    Application.DoEvents()
'Loop

'Dim tmpHTML As String = WebBrowser1.Document.Body.InnerHtml
Dim theWidth As Integer = 500 '1920
Dim theHeight As Integer = 500 '1080
Dim doc As New HtmlDocument()

doc.Load("C:\kathryn\fp.html")
'doc.LoadHtml(tmpHTML)

Dim theVidURL As String = doc.DocumentNode.SelectSingleNode("//OBJECT/PARAM[@NAME='Movie']").Attributes("VALUE").Value

为了在这个 HTML 源中找到电影的 URL:

<DIV id=player-wrapper>
<DIV id=lcm_video>
<OBJECT id=player codeBase="http://0000.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=480 align=middle height=320 VIEWASTEXT><PARAM NAME="_cx" VALUE="12700"><PARAM NAME="_cy" VALUE="8466"><PARAM NAME="FlashVars" VALUE=""><PARAM NAME="Movie" VALUE="http://0000.lightcastmedia.com/lcplayer_flash112fix.swf?autoStart=1&amp;hidecontrols=1&amp;&amp;noresize=1&amp;file=http%3A%2F%2F%2Fedge2%2F3157%2F070712b&amp;rtmppath=rtmp%3A//chi02.live.lightcastmedia.com%3A1935/mc/_definst_&amp;rtmpfile=fvc/3157/070712b&amp;sec=447"><PARAM NAME="Src" VALUE="http://0000.lightcastmedia.com/lcplayer_flash112fix.swf?autoStart=1&amp;hidecontrols=1&amp;&amp;noresize=1&amp;file=http%3A%2F%2F%2Fedge2%2F3157%2F070712b&amp;rtmppath=rtmp%3A//chi02.live.lightcastmedia.com%3A1935/mc/_definst_&amp;rtmpfile=fvc/3157/070712b&amp;sec=447"><PARAM NAME="WMode" VALUE="Window"><PARAM NAME="Play" VALUE="-1"><PARAM NAME="Loop" VALUE="-1"><PARAM NAME="Quality" VALUE="High"><PARAM NAME="SAlign" VALUE=""><PARAM NAME="Menu" VALUE="-1"><PARAM NAME="Base" VALUE=""><PARAM NAME="AllowScriptAccess" VALUE="sameDomain"><PARAM NAME="Scale" VALUE="ShowAll"><PARAM NAME="DeviceFont" VALUE="0"><PARAM NAME="EmbedMovie" VALUE="0"><PARAM NAME="BGColor" VALUE="000000"><PARAM NAME="SWRemote" VALUE=""><PARAM NAME="MovieData" VALUE=""><PARAM NAME="SeamlessTabbing" VALUE="1"><PARAM NAME="Profile" VALUE="0"><PARAM NAME="ProfileAddress" VALUE=""><PARAM NAME="ProfilePort" VALUE="0"><PARAM NAME="AllowNetworking" VALUE="all"><PARAM NAME="AllowFullScreen" VALUE="true"><PARAM NAME="AllowFullScreenInteractive" VALUE="false">

        <embed src="http://0000.lightcastmedia.com/lcplayer_flash112fix.swf?autoStart=1&hidecontrols=1&&noresize=1&file=http%3A%2F%2F%2Fedge2%2F3157%2F070712b&rtmppath=rtmp%3A//chi02.live.lightcastmedia.com%3A1935/mc/_definst_&rtmpfile=fvc/3157/070712b&sec=447" quality="best" FlashVars="" bgcolor="#000000" width="480" height="320" name="player" align="middle" allowScriptAccess="sameDomain"  allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </OBJECT></DIV>

但是由于某种原因,我从theVidURL返回了Nothing

任何帮助都会很棒!

更新

我刚刚结束了使用这段代码来查看 HTML:

Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("PARAM")
For Each curElement As HtmlElement In theElementCollection
    If InStr(curElement.GetAttribute("value"), "lightcastmedia.com") <> 0 Then
        tmpMovieURL = curElement.GetAttribute("value")
        Exit For
    End If
Next
4

2 回答 2

1

那么这是你的问题,你加载的html文件错误。该LoadHtml()方法用于将包含 HTML 的字符串解析为HtmlDocument. 如果你想打开一个 HTML 文件,你可以使用这个Load()方法。

Dim doc As New HtmlDocument
doc.Load("C:\kathryn\fp.html") ' load the file
于 2012-07-09T19:16:03.187 回答
0

我刚刚结束了使用这段代码来查看 HTML:

Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("PARAM")
For Each curElement As HtmlElement In theElementCollection
    If InStr(curElement.GetAttribute("value"), "lightcastmedia.com") <> 0 Then
        tmpMovieURL = curElement.GetAttribute("value")
        Exit For
    End If
Next
于 2012-07-09T20:15:12.057 回答