问题
<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?
回答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
replace Url with your link
来源:https://stackoverflow.com/questions/8302376/how-can-i-process-the-response-stream-from-a-webpage-that-displays-a-video