There might be a better way, but this is what I use.
Code:Public Function GaiaLogin(ByVal username As String, ByVal password As String) As Boolean Dim input As String = GetStringBetween(wrapper.GetWrapper("http://www.gaiaonline.com/auth/login"), "method=""post"">", "<div").Replace("data-value", vbNull) Dim i1 As String = "<input" Dim i2 As String = "/>" Dim token As String = "token" Dim sample, strHTML, strPostData As String Dim var(3) As String Dim val(3) As String Dim tokenIndex As Integer For i As Integer = 0 To 3 sample = GetStringBetween(input, "<input", "/>") var(i) = GetStringBetween(input, "name=""", """") val(i) = GetStringBetween(input, "value=""", """") input = input.Replace(i1 & sample & i2, vbNull) Next tokenIndex = (Array.FindIndex(var, Function(i) i = token)) strPostData = var(0) & "=" & val(0) _ & "&" & var(1) & "=" & val(1) _ & "&" & var(2) & "=" & val(2) _ & "&" & var(3) & "=" & val(3) _ & "&username=" & (username) & "&password=" & "" & "&signInButton=Log+In&chap=" & MD5(MD5(password) + val(tokenIndex)) strHTML = wrapper.PostWrapper("www.gaiaonline.com/auth/login/", strPostData) If strHTML.Contains("<title>Welcome to Gaia | Gaia Online</title>") = True Then GaiaLogin = True Else GaiaLogin = False End If End FunctionCode:Public Function GetStringBetween(ByVal InputText As String, ByVal StartText As String, ByVal EndText As String, Optional ByVal StartPosition As Object = 1) As String Dim lnTextStart As Integer Dim lnTextEnd As Integer lnTextStart = InStr(StartPosition, InputText, StartText, CompareMethod.Text) + Len(StartText) lnTextEnd = InStr(lnTextStart, InputText, EndText, CompareMethod.Text) If lnTextStart >= (StartPosition + Len(StartText)) And lnTextEnd > lnTextStart Then GetStringBetween = Mid(InputText, lnTextStart, lnTextEnd - lnTextStart) Else GetStringBetween = "" End If End Function
Results 1 to 1 of 1
- 20 Jun. 2012 09:44pm #1
Moderator Bachelor of Science in Virginity
- Age
- 31
- Join Date
- Nov. 2009
- Location
- Toronto
- Posts
- 5,421
- Reputation
- 546
- LCash (Rank 3)
- 1.96
[VB.net] GaiaOnline login (6/20/2012)