如何使用VB.net获取html页面的源代码? [英] How to get the source code of a html page using VB.net?

查看:356
本文介绍了如何使用VB.net获取html页面的源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,获取一个带有视频的网页的源代码。然后使用正则表达式隔离该视频的下载链接。那么它使用 httpwebrequest httpwebresponse 下载视频。我的问题出现在某些网站有一个页面,您必须点击继续才能访问视频页面。

I'm writing a program that gets the source code of a web page with a video on it. It then uses regular expressions to isolate the download link of that video. then it uses httpwebrequest and httpwebresponse to download the video. My problem arises when certain sites have a page where you have to click continue in order to get to the video page.

例如, http:/ /nextgenvidz.com/view/s995xvc9e2fv 被称为 The.Matrix.Reloaded.2003.mp4 ,所以我告诉我的程序获取url的源代码 http://nextgenvidz.com/view/s995xvc9e2fv 但由于正在搜索该文件,因此无法找到该视频的下载链接在继续页面的源代码中。如果你去上面的网站查看来源,你将看不到链接。然后,单击继续,并在视频出现时执行相同操作,并注意到文件仅在第二个文件中。

For example, there is a video playing on http://nextgenvidz.com/view/s995xvc9e2fv called "The.Matrix.Reloaded.2003.mp4" so I tell my program to get the source code for the url "http://nextgenvidz.com/view/s995xvc9e2fv" but it can't find the video's download link because it's searching for the file in the "continue" page's source code. If you go to that website above and view source, you won't see the link. Then, click continue and do the same when the video appears and you'll notice that the file is only there in the second one.

如何获取源代码对于视频正在播放的页面,而不是我必须点击的页面继续?

How can I get the source code for the page that the video is playing on, and not the page where I have to click continue?

我正在尝试使用以下代码:

I am trying to use this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Loading As String = "Loading..."
    TextBox1.Text = Loading
    Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(TextBox2.Text)
    Dim response As System.Net.HttpWebResponse = request.GetResponse()

    Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

    Dim sourcecode As String = sr.ReadToEnd()
    TextBox1.Text = sourcecode
End Sub

也许有一种方法来自动选择连续 ue按钮编程?

Maybe there's a way to auto select the "Continue" button programmatically?

推荐答案

这个人回答得很好。

如何获取VB.NET网站的HTML页面源?

这是他的代码:

Dim sourceString As String = New System.Net.WebClient().DownloadString("SomeWebPage")

这篇关于如何使用VB.net获取html页面的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆