Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function siteRequest(url As String, ByVal Method As String, Optional ByVal data As String = Nothing) As String
- Static soucrecode As String = Nothing
- Const UserAgent As String = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
- Try
- Dim Request As Net.HttpWebRequest = Net.WebRequest.Create(url)
- Request.Accept = "*/*"
- Request.Timeout = 10000
- Request.Method = Method
- Request.UserAgent = UserAgent
- Request.AllowAutoRedirect = True
- Request.CookieContainer = siteCookies
- If Request.Method = "POST" AndAlso data IsNot Nothing Then
- Dim postBytes() As Byte = New UTF8Encoding().GetBytes(data)
- Request.ContentType = "application/x-www-form-urlencoded"
- Request.ContentLength = postBytes.Length
- Request.GetRequestStream().Write(postBytes, 0, postBytes.Length)
- End If
- Dim Response As Net.HttpWebResponse = Request.GetResponse()
- soucrecode = New IO.StreamReader(Response.GetResponseStream).ReadToEnd()
- Response.Close()
- Catch e As Exception
- MsgBox(e.Message, MsgBoxStyle.Critical)
- End Try
- Return soucrecode
- End Function
- txtLoginSoucre.Text = siteRequest("http://www.SomeSite.com/login.php?do=login", "Post", "username=myUser&password=MyPass") ' Login to site
- txtSoucre.Text siteRequest("http: //www.SomeSite.com", "Get") Grab soucrecode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement