Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net
- Imports System.Text
- Imports System.IO
- Imports System.Text.RegularExpressions
- Imports System.Threading
- Public Class QuoraLogin
- Public Function Login(email As String, pass As String, proxyinfo As String) As CookieContainer
- Dim logincookie As New CookieContainer
- Dim ids = GetUniqueIDs("https://www.quora.com/", proxyinfo, logincookie)
- Dim postData As String = "json=%7B%22args%22%3A%5B%5D%2C%22kwargs%22%3A%7B%22email%22%3A%22" & email & "%22%2C%22password%22%3A%22" & pass & "%22%2C%22passwordless%22%3A1%7D%7D&formkey=" & ids.FormId & "&postkey=" & ids.PostKey & "&window_id=" & ids.windowId & "&referring_controller=index&referring_action=index&_lm_transaction_id=0.168214091389562&_lm_window_id=dep3004-268454598272995956&__vcon_json=%5B%22Vn03YsuKFZvHV9%22%5D&__vcon_method=do_login&__e2e_action_id=ecwlr32628&js_init=%7B%7D"
- Dim result = MobilePost(postData, logincookie, proxyinfo)
- Return logincookie
- End Function
- Public Function MobilePost(postData As String, logincookie As CookieContainer, proxyinfo As String) As String
- Try
- Dim myProxy As WebProxy
- Dim proxynumber As String = ""
- Dim proxyport As Integer
- Dim ProxyUser As String = ""
- Dim ProxyPass As String = ""
- If Not proxyinfo = "" Then
- If proxyinfo.Split(":").Length > 2 Then
- Dim proxycode As String() = proxyinfo.Split(":")
- proxynumber = proxycode(0)
- proxyport = proxycode(1)
- ProxyUser = proxycode(2)
- ProxyPass = proxycode(3)
- Else
- Dim proxycode As String() = proxyinfo.Split(":")
- proxynumber = proxycode(0)
- proxyport = proxycode(1)
- End If
- myProxy = New WebProxy(proxynumber & ":" & proxyport, True)
- End If
- Dim encoding As New UTF8Encoding
- Dim byteData As Byte() = encoding.GetBytes(postData)
- Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://www.quora.com/webnode2/server_call_POST"), HttpWebRequest)
- postReq.KeepAlive = False
- If Not proxyinfo = "" Then
- postReq.Proxy = myProxy
- If proxyinfo.Split(":").Length > 2 Then
- myProxy.Credentials = New NetworkCredential(ProxyUser, ProxyPass)
- End If
- End If
- postReq.Method = "POST"
- postReq.CookieContainer = logincookie
- postReq.ContentType = "application/x-www-form-urlencoded"
- postReq.Referer = "https://www.quora.com/"
- postReq.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/27.0.1453.10 Mobile/10B350 Safari/8536.25"
- postReq.ContentLength = byteData.Length
- Dim postreqstream As Stream = postReq.GetRequestStream()
- postreqstream.Write(byteData, 0, byteData.Length)
- postreqstream.Close()
- Dim postresponse As HttpWebResponse
- postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
- logincookie.Add(postresponse.Cookies)
- logincookie = logincookie
- Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
- Dim thepage As String = postreqreader.ReadToEnd
- postresponse.Close()
- Return thepage
- Catch
- Return "error"
- End Try
- End Function
- Public Function GetUniqueIDs(url As String, proxyinfo As String, logincookie As CookieContainer) As UniqueIDs
- Try
- Dim myProxy As WebProxy
- Dim proxynumber As String = ""
- Dim proxyport As Integer
- Dim ProxyUser As String = ""
- Dim ProxyPass As String = ""
- If Not proxyinfo = "" Then
- If proxyinfo.Split(":").Length > 2 Then
- Dim proxycode As String() = proxyinfo.Split(":")
- proxynumber = proxycode(0)
- proxyport = proxycode(1)
- ProxyUser = proxycode(2)
- ProxyPass = proxycode(3)
- Else
- Dim proxycode As String() = proxyinfo.Split(":")
- proxynumber = proxycode(0)
- proxyport = proxycode(1)
- End If
- myProxy = New WebProxy(proxynumber & ":" & proxyport, True)
- End If
- Dim uri As New Uri(url)
- Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
- request.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/27.0.1453.10 Mobile/10B350 Safari/8536.25"
- If Not proxyinfo = "" Then
- request.Proxy = myProxy
- If proxyinfo.Split(":").Length > 2 Then
- myProxy.Credentials = New NetworkCredential(ProxyUser, ProxyPass)
- End If
- End If
- request.Method = WebRequestMethods.Http.Get
- request.CookieContainer = logincookie
- Dim response As HttpWebResponse = request.GetResponse()
- logincookie.Add(response.Cookies)
- Dim reader As New IO.StreamReader(response.GetResponseStream())
- Dim tmp As String = reader.ReadToEnd()
- Dim uniqueids As New UniqueIDs
- uniqueids.response = tmp
- uniqueids.FormId = GetformKey(tmp)
- uniqueids.MobileWindowID = GetWindowId(tmp)
- uniqueids.PostKey = GetPostKey(tmp)
- response.Close()
- Return uniqueids
- Catch ex As Exception
- Dim uniqueids As New UniqueIDs
- uniqueids.response = "error"
- Return uniqueids
- End Try
- End Function
- Public Function GetWindowId(ByVal page) As String
- Dim myRegex As New Regex("fake_window_(.*?)""")
- Dim t As String = page
- Return myRegex.Match(t).Groups(1).ToString
- End Function
- Public Function GetformKey(ByVal page) As String
- Dim myRegex As New Regex("formkey"": ""(.*)"", ""isLoggedIn")
- Dim t As String = page
- Return myRegex.Match(t).Groups(1).ToString
- End Function
- Public Function GetPostKey(ByVal page) As String
- Dim myRegex As New Regex("postkey"": ""(.*)"", ""save_feed_story_debug")
- Dim t As String = page
- Return myRegex.Match(t).Groups(1).ToString
- End Function
- Public Structure UniqueIDs
- Public FormId As String
- Public windowId As String
- Public MobileWindowID As String
- Public PostKey As String
- Public ProfileId As String
- Public voterid As String
- Public optimisticcount As String
- Public response As String
- End Structure
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement