【问题标题】:How can I process the response stream from a webpage that displays a video?如何处理来自显示视频的网页的响应流?
【发布时间】:2012-01-08 07:08:45
【问题描述】:
<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>

如果我输入the URL,上面是我试图得到的页面的响应:

但是,程序只是因以下代码而崩溃(即,甚至从未显示 final - 意味着流仍在继续)

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

如何检索此来源?

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 时,消息来源只是说“技术困难”。我该如何进行?

【问题讨论】:

  • 你想在响应流中获取页面的源代码吗?
  • @m.qayyum 完全正确:无需下载视频!

标签: vb.net video stream httpwebrequest httpwebresponse


【解决方案1】:
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

【讨论】:

  • av.vimeo.com/32372/157/… 此链接不可用,因此您请求的 url 不存在并给您错误....我想您想获取该 .mp4 文件的信息网站....
  • 别担心链接有效(我的程序每次都会生成一个新链接)!
  • 通常.mp4文件不包含html源代码...尝试读取文件的前几个字节然后检查该文件...stackoverflow.com/questions/5863786/…
猜你喜欢
  • 1970-01-01
  • 2017-11-08
  • 2013-10-08
  • 2011-09-21
  • 2016-08-05
相关资源
最近更新 更多