function for urlcheck
-
hi there, can any one tell me how to write a function to check the validate url in database Thanks in advance cyus
Could you provide more information on what you're trying to accomplish? ~Javier Lozano
-
Could you provide more information on what you're trying to accomplish? ~Javier Lozano
Hii javier, this is the scenario i have a database which has 2000 records in that one field is url will i have to check whether the given url is having valid connection r broken connection for that iam using a function which is the following... cod snippet Public Function checkurl(ByVal url As String) As String Dim req As System.Net.HttpWebRequest Dim res As System.Net.HttpWebResponse Dim r As System.IO.StreamReader Dim ex As Exception 'error exeption holder Dim pge As String 'page holder ' If Page.IsPostBack Then 'ReqUrl.Text = Textbox1.Text 'set up error trapping Dim strerr As String = "" Try 'display request url req = req.Create(url) 'set the user agent 'some site might brush you off if it is not set 'to stop bots and scrapers req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)" 'get page res = req.GetResponse() r = New System.IO.StreamReader(res.GetResponseStream()) pge = r.ReadToEnd r.Close() res.Close() 'display respondent url Dim struri As String = res.ResponseUri.AbsoluteUri 'extract and display meta refresh tag, if it exists Dim strpge As String = System.Text.RegularExpressions.Regex.Match(pge, "URL=(?[^""]+)""").Groups("href").Value() 'extract and display page title Dim strtit As String = System.Text.RegularExpressions.Regex.Match(pge, "(?<title>[^<]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Groups("title").Value Dim SHhash As New System.Security.Cryptography.SHA1Managed 'convert the page to a byte array Dim pgeb As Byte() = System.Text.Encoding.ASCII.GetBytes(pge) 'get the hash as a byte array Dim hashvalue As Byte() = SHhash.ComputeHash(pgeb) 'display the hash as a string strerr = "" Catch ex 'display any error message strerr = ex.Message End Try End Function Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then 'SqlDataAdapter1.Fill(DsResult) 'DataGrid1.DataBind() If DsResult.Tables(0).Rows.Count >
-
Could you provide more information on what you're trying to accomplish? ~Javier Lozano
Hi javier, this is the scenario i have a database which has 2000 records in that one field is url will i have to check whether the given url is having valid connection r broken connection for that iam using a function which is the following... the code snippet Public Function checkurl(ByVal url As String) As String Dim req As System.Net.HttpWebRequest Dim res As System.Net.HttpWebResponse Dim r As System.IO.StreamReader Dim ex As Exception 'error exeption holder Dim pge As String 'page holder 'set up error trapping Dim strerr As String = "" Try 'display request url req = req.Create(url) 'set the user agent 'some site might brush you off if it is not set 'to stop bots and scrapers req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)" 'get page res = req.GetResponse() r = New System.IO.StreamReader(res.GetResponseStream()) pge = r.ReadToEnd r.Close() res.Close() 'display respondent url Dim struri As String = res.ResponseUri.AbsoluteUri 'extract and display meta refresh tag, if it exists Dim strpge As String = System.Text.RegularExpressions.Regex.Match(pge, "URL=(?[^""]+)""").Groups("href").Value() 'extract and display page title Dim strtit As String = System.Text.RegularExpressions.Regex.Match(pge, "(?<title>[^<]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Groups("title").Value Dim SHhash As New System.Security.Cryptography.SHA1Managed 'convert the page to a byte array Dim pgeb As Byte() = System.Text.Encoding.ASCII.GetBytes(pge) 'get the hash as a byte array Dim hashvalue As Byte() = SHhash.ComputeHash(pgeb) 'display the hash as a string strerr = "" Catch ex 'display any error message strerr = ex.Message End Try End Function Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then SqlDataAdapter1.Fill(DsResult) 'DataGrid1.DataBind() If DsResult.Tables(0).Rows.Count > 0 Then For I As Integer = 0 To DsResult.Tables(0).Rows.Coun