Share Pastebin
Guest
Private paste!

Untitled

By: a guest | Apr 12th, 2010 | Syntax: VB.NET | Size: 1.21 KB | Hits: 139 | Expires: Never
Copy text to clipboard
  1. Imports System.Text
  2. Imports System.Web
  3. Imports System.IO
  4. Imports System.Net
  5.  
  6. Module Module1
  7.  
  8.     Sub Main(ByVal sArgs() As String)
  9.  
  10.         If sArgs.Length = 0 Then                'If there are no arguments
  11.             Console.WriteLine("You need to specify a url")
  12.         Else                                    'We have some arguments        
  13.             Dim url As String
  14.             Dim request As HttpWebRequest = Nothing
  15.             Dim response As HttpWebResponse
  16.  
  17.             url = sArgs(0)
  18.  
  19.             Try
  20.                 request = WebRequest.Create(url)
  21.                 request.Timeout = 5000
  22.                 request.UserAgent = ""
  23.                 response = request.GetResponse()
  24.                 Dim stream As Stream = response.GetResponseStream()
  25.                 Dim reader As StreamReader = New StreamReader(stream)
  26.                 Dim html As String = reader.ReadToEnd
  27.                 Console.WriteLine(html)
  28.                 'if error occurs then application doesnt crash
  29.             Catch ex0 As WebException
  30.                 Console.WriteLine(ex0.Message)
  31.             Catch ex As Exception
  32.                 Console.WriteLine(ex.Message)
  33.             End Try
  34.  
  35.         End If
  36.  
  37.         Console.ReadLine()
  38.  
  39.     End Sub
  40.  
  41. End Module