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 に答える