vb.net 从浏览器获取值到文本框

vb.net Get value from webbrowser to textbox

我正在尝试编写代码以从某个网站下载电影,但我一直试图将此值添加到文本框,但是此代码的其余部分已经完成,所以我认为,将会有没有其他问题。这是来自网站的代码:`

        <div style="width:750px;z-index: 0;background:#000;color:#FFF;text-align:center">
                <div class="embed">
                            <div style="height:429px;width:750px;z-index:0;position:relative;clear:both">
                <span id="206019b3744f78869b9bd120161c7b25"><object width="100%" height="100%" id="206019b3744f78869b9bd120161c7b25_api" name="206019b3744f78869b9bd120161c7b25_api" data="http://premium.iitv.info/static/player/flowplayer.commercial-3.2.15.swf" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="quality" value="high"><param name="bgcolor" value="#000000"><param name="flashvars" value="config={&quot;key&quot;:&quot;#f90d28e7547ada6c98&quot;,&quot;clip&quot;:{&quot;url&quot;:&quot;http://stream.streamo.tv/?scode=w0GCOWxpkyGA4MJoRu2ETWHHZI3ZEIHojZHZPERJI9PIO90YyE0XMEQF3qUBQA1nkERocWaLaWxEipGn4cHGuuRIH9FnaM3p3fzZHq0oxyHBOERo5AGJvSKoUuHok80X4IwoIq3FhuJBe1RI5AJp30zE4MKpYS0DRAGoKczo5VmIPkTMSIzovWRpvOmE1pwM3gTo65JrlDILSyzFGMHIGWyG1c2G3pzJcEKIX9TJ0NQrSWGp1jxF4IUqeg2nepaqL5RG2cRr55zAaIKIYIKIEWwpCWJHnqmLzA1Z19RqeZmZJcUMeymoeDJGQg2pvkJq3NaZ1x2LzqyIVWyH5f2pLgTMCyIHMW1XcSzDREIGlqyDd50LIyIpbyHL1HyIUImEwuTrGAxnbuxD192Y61HLnSyHL9HBxyUokkHJj92LUSyEFMxAi1xnP1TqGWRrnSUB0N3H1W2ZTATGZyJBcWTrvIxq2LKnf9TnjSJnjtKoUy1E6WaoiZTIT52HjWSZh9RFxMJJaAmEcSKF&quot;,&quot;provider&quot;:&quot;lighttpd&quot;,&quot;scaling&quot;:&quot;fit&quot;,&quot;backgroundGradient&quot;:&quot;none&quot;,&quot;autoPlay&quot;:false,&quot;autoBuffering&quot;:false},&quot;canvas&quot;:{&quot;backgroundColor&quot;:&quot;#000&quot;,&quot;backgroundGradient&quot;:&quot;none&quot;},&quot;plugins&quot;:{&quot;lighttpd&quot;:{&quot;url&quot;:&quot;flowplayer.pseudostreaming-3.2.11.swf&quot;,&quot;queryString&quot;:&quot;%3Fstart%3D%24%7Bstart%7D&quot;},&quot;controls&quot;:{&quot;url&quot;:&quot;flowplayer.controls-3.2.14.swf&quot;,&quot;autoHide&quot;:&quot;always&quot;}},&quot;playerId&quot;:&quot;206019b3744f78869b9bd120161c7b25&quot;,&quot;playlist&quot;:[{&quot;url&quot;:&quot;http://stream.streamo.tv/?scode=w0GCOWxpkyGA4MJoRu2ETWHHZI3ZEIHojZHZPERJI9PIO90YyE0XMEQF3qUBQA1nkERocWaLaWxEipGn4cHGuuRIH9FnaM3p3fzZHq0oxyHBOERo5AGJvSKoUuHok80X4IwoIq3FhuJBe1RI5AJp30zE4MKpYS0DRAGoKczo5VmIPkTMSIzovWRpvOmE1pwM3gTo65JrlDILSyzFGMHIGWyG1c2G3pzJcEKIX9TJ0NQrSWGp1jxF4IUqeg2nepaqL5RG2cRr55zAaIKIYIKIEWwpCWJHnqmLzA1Z19RqeZmZJcUMeymoeDJGQg2pvkJq3NaZ1x2LzqyIVWyH5f2pLgTMCyIHMW1XcSzDREIGlqyDd50LIyIpbyHL1HyIUImEwuTrGAxnbuxD192Y61HLnSyHL9HBxyUokkHJj92LUSyEFMxAi1xnP1TqGWRrnSUB0N3H1W2ZTATGZyJBcWTrvIxq2LKnf9TnjSJnjtKoUy1E6WaoiZTIT52HjWSZh9RFxMJJaAmEcSKF&quot;,&quot;provider&quot;:&quot;lighttpd&quot;,&quot;scaling&quot;:&quot;fit&quot;,&quot;backgroundGradient&quot;:&quot;none&quot;,&quot;autoPlay&quot;:false,&quot;autoBuffering&quot;:false}]}"></object></span>`

我想得到这个:

<param name="flashvars" value="config={&quot;key&quot;:&quot;#f90d28e7547ada6c98&quot;,&quot;clip&quot;:{&quot;url&quot;:&quot;http://stream.streamo.tv/?scode=w0GCOWxpkyGA4MJoRu2ETWHHZI3ZEIHojZHZPERJI9PIO90YyE0XMEQF3qUBQA1nkERocWaLaWxEipGn4cHGuuRIH9FnaM3p3fzZHq0oxyHBOERo5AGJvSKoUuHok80X4IwoIq3FhuJBe1RI5AJp30zE4MKpYS0DRAGoKczo5VmIPkTMSIzovWRpvOmE1pwM3gTo65JrlDILSyzFGMHIGWyG1c2G3pzJcEKIX9TJ0NQrSWGp1jxF4IUqeg2nepaqL5RG2cRr55zAaIKIYIKIEWwpCWJHnqmLzA1Z19RqeZmZJcUMeymoeDJGQg2pvkJq3NaZ1x2LzqyIVWyH5f2pLgTMCyIHMW1XcSzDREIGlqyDd50LIyIpbyHL1HyIUImEwuTrGAxnbuxD192Y61HLnSyHL9HBxyUokkHJj92LUSyEFMxAi1xnP1TqGWRrnSUB0N3H1W2ZTATGZyJBcWTrvIxq2LKnf9TnjSJnjtKoUy1E6WaoiZTIT52HjWSZh9RFxMJJaAmEcSKF&quot;,&quot;provider&quot;:&quot;lighttpd&quot;,&quot;scaling&quot;:&quot;fit&quot;,&quot;backgroundGradient&quot;:&quot;none&quot;,&quot;autoPlay&quot;:false,&quot;autoBuffering&quot;:false},&quot;canvas&quot;:{&quot;backgroundColor&quot;:&quot;#000&quot;,&quot;backgroundGradient&quot;:&quot;none&quot;},&quot;plugins&quot;:{&quot;lighttpd&quot;:{&quot;url&quot;:&quot;flowplayer.pseudostreaming-3.2.11.swf&quot;,&quot;queryString&quot;:&quot;%3Fstart%3D%24%7Bstart%7D&quot;},&quot;controls&quot;:{&quot;url&quot;:&quot;flowplayer.controls-3.2.14.swf&quot;,&quot;autoHide&quot;:&quot;always&quot;}},&quot;playerId&quot;:&quot;206019b3744f78869b9bd120161c7b25&quot;,&quot;playlist&quot;:[{&quot;url&quot;:&quot;http://stream.streamo.tv/?scode=w0GCOWxpkyGA4MJoRu2ETWHHZI3ZEIHojZHZPERJI9PIO90YyE0XMEQF3qUBQA1nkERocWaLaWxEipGn4cHGuuRIH9FnaM3p3fzZHq0oxyHBOERo5AGJvSKoUuHok80X4IwoIq3FhuJBe1RI5AJp30zE4MKpYS0DRAGoKczo5VmIPkTMSIzovWRpvOmE1pwM3gTo65JrlDILSyzFGMHIGWyG1c2G3pzJcEKIX9TJ0NQrSWGp1jxF4IUqeg2nepaqL5RG2cRr55zAaIKIYIKIEWwpCWJHnqmLzA1Z19RqeZmZJcUMeymoeDJGQg2pvkJq3NaZ1x2LzqyIVWyH5f2pLgTMCyIHMW1XcSzDREIGlqyDd50LIyIpbyHL1HyIUImEwuTrGAxnbuxD192Y61HLnSyHL9HBxyUokkHJj92LUSyEFMxAi1xnP1TqGWRrnSUB0N3H1W2ZTATGZyJBcWTrvIxq2LKnf9TnjSJnjtKoUy1E6WaoiZTIT52HjWSZh9RFxMJJaAmEcSKF&quot;,&quot;provider&quot;:&quot;lighttpd&quot;,&quot;scaling&quot;:&quot;fit&quot;,&quot;backgroundGradient&quot;:&quot;none&quot;,&quot;autoPlay&quot;:false,&quot;autoBuffering&quot;:false}]}">

如果有必要,它可能是完整的 4 行。

过去 5 个小时我一直在寻找解决方案,但找不到任何有用的东西...

一个快速而肮脏的方法是:

1) 使用以下代码将网页的HTML内容下载成字符串:

Dim htmlContent As String = New System.Net.WebClient().DownloadString(<Enter URL Here>)

2) ... 然后在字符串中搜索您的代码。一种方法是首先定位字符串“http://stream.streamo.tv/?scode=”在 HTML 中的哪个位置 ...

Dim codeLocation As Integer = htmlContent.IndexOf("http://stream.streamo.tv/?scode=")

然后遍历每个后续字符,逐个字符构建代码,直到到达终止字符(如“&”)。

我假设这段代码只在页面上出现一次。如果没有,您将需要找到一种循环遍历每个实例的方法(不难但未在此处介绍)。

也许可以,但它是 html 代码的动态部分,因此页面源代码中没有 link,只有 select [=24] 才能找到它=] 函数...

我正在尝试做这样的事情,但找不到可行的解决方案...:[=​​14=]

For Each h As HtmlElement In WebBrowser1.Document.GetElementsByTagName("value")
If Not Object.ReferenceEquals(h.GetAttribute("name"), Nothing) AndAlso h.GetAttribute("name").Equals("flashvars") Then
Tbox1.Text = h.InnerText
Exit For
End If
Next

如果我这样做:

(...).SetAttribute("Value", TextBox4.Text)

那我就可以在这里设置数据了:

<param name="flashvars" value="here"></param>

但我不知道如何反转它并将其放入文本框:

?textbox1..AppendText(WebBrowser1.Document.GetAttribute("value")?

ChicagoMike 感谢您给我下载源代码并搜索它们的想法,但问题是如何 运行 javascript 早些时候,但我设法通过这种方式解决了这个问题:

WebBrowser1.Document.Window.DomWindow.execscript("text/JavaScript")

    Dim MSDNpage2 As String = WebBrowser1.Document.Body.InnerHtml

    My.Computer.FileSystem.WriteAllText("e:\msdn2.txt", MSDNpage2, True)

    RichTextBox6.Text = MSDNpage2