如何处理来自显示视频的网页的响应流?

发布于 2024-12-18 14:03:31 字数 1195 浏览 1 评论 0原文

<html>
    <body style="background-color: rgb(38,38,38);">
        <video controls="" autoplay="" name="media"
            style="margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;"
            src="http://av.vimeo.com/32372/157/24910156.mp4?token=1322514534_58acf41d56103820e9fe93763c73fadd">
        </video>
    </body>
</html>

上面是我输入 URL 时尝试获取的页面响应

但是,程序只是崩溃了以下代码(即从未显示最终 - 意味着流仍在继续)

我认为除了源之外,它还在流式传输视频 - 我不希望发生这种情况

我如何检索此源?

Dim final As String = ""
Dim request1 As HttpWebRequest = DirectCast(WebRequest.Create(urlvimeohd), HttpWebRequest)

request1.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
Dim response1 As HttpWebResponse = DirectCast(request1.GetResponse(), HttpWebResponse)

final = New StreamReader(response1.GetResponseStream).ReadToEnd
MessageBox.Show(final)

我只想要网页的来源。当我尝试 webbrowser1.navigate 时,消息来源只是说“技术困难”。我该如何继续?

<html>
    <body style="background-color: rgb(38,38,38);">
        <video controls="" autoplay="" name="media"
            style="margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;"
            src="http://av.vimeo.com/32372/157/24910156.mp4?token=1322514534_58acf41d56103820e9fe93763c73fadd">
        </video>
    </body>
</html>

Above is the response of the page I am trying to get if I enter the URL:

However, the program just crashes with the following code (i.e. never even displays final - meaning stream is still going on)

I think that it is streaming the video, in addition to the source- which I do not want to happen

How can I retrieve this source?

Dim final As String = ""
Dim request1 As HttpWebRequest = DirectCast(WebRequest.Create(urlvimeohd), HttpWebRequest)

request1.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
Dim response1 As HttpWebResponse = DirectCast(request1.GetResponse(), HttpWebResponse)

final = New StreamReader(response1.GetResponseStream).ReadToEnd
MessageBox.Show(final)

I just want the source of the webpage. When I try webbrowser1.navigate, the source just says "technical difficulties". How can I proceed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不疑不惑不回忆 2024-12-25 14:03:32
HttpWebRequest request = DirectCast(HttpWebRequest.Create(Url), HttpWebRequest)HttpWebResponse resp = DirectCast(request.GetResponse, HttpWebResponse)
string sourcecode = New StreamReader(resp.GetResponseStream,System.Text.Encoding.Default).ReadToEnd

将 URL 替换为您的链接

HttpWebRequest request = DirectCast(HttpWebRequest.Create(Url), HttpWebRequest)HttpWebResponse resp = DirectCast(request.GetResponse, HttpWebResponse)
string sourcecode = New StreamReader(resp.GetResponseStream,System.Text.Encoding.Default).ReadToEnd

replace Url with your link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文