Страница: 1 | 2 |
Вопрос: Помогите переделать код плз..
Добавлено: 05.04.11 21:02
Автор вопроса: MISTER X | Web-сайт: studioartf.ru | ICQ: 463865965
Помогите переделать код на vb6 плз..
public bool Auth(String email,String pass) {
HttpWebRequest wrGETURL = (HttpWebRequest)System.Net.WebRequest.Create(
"http://vkontakte.ru/login.php?m=1&email=" + email + "&pass=" + pass
);
wrGETURL.AllowAutoRedirect = false;
wrGETURL.Timeout = 100000;
string headers = wrGETURL.GetResponse().Headers.ToString();
HttpWebResponse myHttpWebResponse = (HttpWebResponse)wrGETURL.GetResponse();
StreamReader myStreamReadermy = new StreamReader(myHttpWebResponse.GetResponseStream(), Encoding.GetEncoding(1251));
string page = myStreamReadermy.ReadToEnd();
MessageBox.Show(page);
Regex sidregex = new Regex("sid=([a-z0-9]+); exp");
Match ssid = sidregex.Match(headers);
string sid = ssid.Groups[1].Value;
cook = new Cookie("remixsid", sid);
if (String .IsNullOrEmpty(sid))
{
return false;
}
return true;
}
Заранее благодарствую :D
Ответить
Номер ответа: 1Автор ответа: gekko
Вопросов: 39Ответов: 127
Web-сайт: kalamfur.ru Профиль | | #1
Добавлено: 05.04.11 21:48
классно) Парсер контакта. Но ИМХО на PHP проще и шустрее будет
Ответить
Номер ответа: 9Автор ответа: AgentFire
ICQ: 192496851 Вопросов: 75Ответов: 3178
Профиль | | #9
Добавлено: 06.04.11 22:24
Файл Mp3 Cluster Server\Account.vb
Imports System.Text.RegularExpressions
Namespace Host.Vk
Public Class Account
Public Event OnBecomeActive As EventHandler
Public Const EmailWildcard As String = "?*@?*.?*"
Public Const SessionGetIntervalMs As Int32 = 1000
Private Shared ReadOnly _ViewerId As New Regex("var[\t\r\n ]+user_id[\t\r\n ]+\=[\t\r\n ]+(?<value>[0-9]+)\;" )
Private Shared ReadOnly _AuthHash As New Regex("var[\t\r\n ]+auth_hash[\t\r\n ]+\=[\t\r\n ]+\'(?<value>[0-9a-f]+)\'\;" )
Private Shared ReadOnly _SessionId As New Regex("\" "sid\" "\:\" "(?<value>[0-9a-f]+)\" "" )
Private Shared ReadOnly _Secret As New Regex("\" "secret\" "\:\" "(?<value>[0-9a-f]+)\" "" )
Private Shared ReadOnly _Mid As New Regex("\" "mid\" "\:(?<value>[0-9a-f]+)" )
Private Shared ReadOnly _Cookie As New Regex("name\=\'s\'[\t\r\n ]+value\=\'(?<cookie>[0-9a-f]+)\'" )
Private Shared ReadOnly _WaitAction As New Action(Of Int32)(AddressOf Threading.Thread.Sleep)
Private ReadOnly _Email As String
Private ReadOnly _Password As String
Private _Session As Vk.Session = Nothing
Private _Available As Boolean = False
Private ReadOnly Property SignInData() As String
Get
Return String .Format("email={0}&pass={1}&expire=&vk=" , Email, Password)
End Get
End Property
Public Function PeekSession() As Session
Return _Session
End Function
Public Function GetSession() As Session
If Not HasSession Then Return Nothing
_Available = False
_WaitAction.BeginInvoke(SessionGetIntervalMs, AddressOf WaitEnded, Nothing )
Return _Session
End Function
Public ReadOnly Property HasSession() As Boolean
Get
Return _Session IsNot Nothing AndAlso _Available
End Get
End Property
Public Sub TurnOff()
_Session = Nothing
_Available = False
End Sub
Public Function UpdateSession() As Boolean
Dim ApplicationPage As String
Using WC As New Net.WebClient
WC.Headers(Net.HttpRequestHeader.Accept) = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"
WC.Headers(Net.HttpRequestHeader.ContentType) = "application/x-www-form-urlencoded"
WC.Headers(Net.HttpRequestHeader.UserAgent) = "Mozilla/4.0 (compatible; ICS)"
Try
ApplicationPage = WC.UploadString("http://login.vk.com/?act=login" , "POST" , SignInData)
Catch
Return False
End Try
Dim Cookie = _Cookie.Match(ApplicationPage).Groups.Item("cookie" ).Value
If String .IsNullOrEmpty(Cookie) Then Return False
Dim Request = DirectCast (Net.WebRequest.Create("http://vkontakte.ru/login.php?app=8&layout=popup&type=browser&settings=8" ), Net.HttpWebRequest)
Request.Headers(Net.HttpRequestHeader.Cookie) = "remixclosed_tabs=0; remixchk=5; remixsid=" + Cookie
Dim RelocatedUrl As Uri
Try
Using Response = Request.GetResponse, Stream = Response.GetResponseStream, R As New IO.StreamReader(Stream)
ApplicationPage = R.ReadToEnd
RelocatedUrl = Response.ResponseUri
End Using
Catch
Return False
End Try
Dim SessionId, Secret, ViewerId As String
If ApplicationPage.Contains("Login success" ) Then
Dim Vars = Uri.UnescapeDataString(RelocatedUrl.Fragment)
ViewerId = _Mid.Match(Vars).Groups.Item("value" ).Value
SessionId = _SessionId.Match(Vars).Groups.Item("value" ).Value
Secret = _Secret.Match(Vars).Groups.Item("value" ).Value
If String .IsNullOrEmpty(ViewerId) Or String .IsNullOrEmpty(SessionId) Or String .IsNullOrEmpty(Secret) Then Return False
Else
Dim AppHash = _AuthHash.Match(ApplicationPage).Groups.Item("value" ).Value
ViewerId = _ViewerId.Match(ApplicationPage).Groups.Item("value" ).Value
If String .IsNullOrEmpty(AppHash) Or String .IsNullOrEmpty(ViewerId) Then Return False
WC.Headers(Net.HttpRequestHeader.Accept) = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"
WC.Headers(Net.HttpRequestHeader.ContentType) = "application/x-www-form-urlencoded"
WC.Headers(Net.HttpRequestHeader.UserAgent) = "Mozilla/4.0 (compatible; ICS)"
WC.Headers(Net.HttpRequestHeader.Cookie) = "remixclosed_tabs=0; remixchk=5; remixsid=" + Cookie
WC.Headers.Add("X-Requested-With" , "XMLHttpRequest" )
Try
Dim Data = String .Format("s={0}&act=auth_result&m=4&app=8&app_hash={1}" , Cookie, AppHash)
ApplicationPage = WC.UploadString("http://vkontakte.ru/login.php" , "POST" , Data)
Catch
Return False
End Try
SessionId = _SessionId.Match(ApplicationPage).Groups.Item("value" ).Value
Secret = _Secret.Match(ApplicationPage).Groups.Item("value" ).Value
If String .IsNullOrEmpty(SessionId) Or String .IsNullOrEmpty(Secret) Then Return False
End If
_Session = New Session(SessionId, Secret, ViewerId)
End Using
_Available = True
Return True
End Function
Public ReadOnly Property Email() As String
Get
Return _Email
End Get
End Property
Public ReadOnly Property Password() As String
Get
Return _Password
End Get
End Property
Public Sub New (ByVal Email As String , ByVal Password As String )
If Email Is Nothing Then Throw New ArgumentNullException("Email" )
If Not Email.Trim Like EmailWildcard Then Throw New ArgumentException("Email parameter doesn't look like real e-mail" )
If String .IsNullOrEmpty(Password) Then Throw New ArgumentNullException("Password" )
_Email = Email.Trim.ToLower
_Password = Password
End Sub
Private Sub WaitEnded(ByVal ar As IAsyncResult)
_Available = True
_WaitAction.EndInvoke(ar)
RaiseEvent OnBecomeActive(Me , System.EventArgs.Empty)
End Sub
Public Overrides Function GetHashCode() As Integer
Return _Email.GetHashCode Xor _Password.GetHashCode
End Function
End Class
End Namespace
Ответить
Номер ответа: 10Автор ответа: Winand
Вопросов: 87Ответов: 2795
Web-сайт: winandfx.narod.ru Профиль | | #10
Добавлено: 06.04.11 23:04
вот кусочек говнокода, используется WebForm, который можно найти на Сером Форуме.
function retrieve(query, offset, email, pass) {
var ret;
WebForm.setStatus("search now" );
ret = search(query, offset);
if (ret == false ) {
ret = "" ;
WebForm.setStatus("login now" );
if (logon(email, pass)) {
WebForm.setStatus("search now" );
ret = search(query, offset);
if (ret == false ) {
ret = "" ;
WebForm.setStatus("search failed due to login ussues" );
} else WebForm.setStatus("search done" );
} else WebForm.setStatus("cannot login to \" " + email + " \"" );
} else WebForm.setStatus("search done" );
return ret;
}
function test() {
return false ;
}
function search(what, offset) {
WebForm.ResetData();
WebForm.Action = "http://vkontakte.ru/gsearch.php?section=audio&q=" + what + "&offset=" + offset;
WebForm.test(WebForm.Action)
WebForm.Method = "GET" ;
WebForm.Enctype = "application/x-www-form-urlencoded" ;
XMLHTTP.open(WebForm.Method, WebForm.Action, true );
XMLHTTP.setRequestHeader("Content-type" , WebForm.Enctype);
XMLHTTP.send(WebForm.VarBody);
WebForm.WaitForXMLHTTPResponse();
if (checklogon(XMLHTTP.responseText))
return extractUrls(XMLHTTP.responseText);
else return false ;
}
function logon(email, pass) {
var s0;
WebForm.ResetData();
WebForm.Action = "http://login.vk.com/" ;//"http://vkontakte.ru/login.php" ;
WebForm.Method = "POST" ;
WebForm.Enctype = "application/x-www-form-urlencoded" ;
WebForm.AddField("act" , "login" );
WebForm.AddField("success_url" , "" );
WebForm.AddField("fail_url" , "" );
WebForm.AddField("try_to_login" , "1" );
WebForm.AddField("to" , "" );
WebForm.AddField("vk" , "1" );
WebForm.AddField("al_test" , "3" );
WebForm.AddField("email" , email);
WebForm.AddField("pass" , pass);
XMLHTTP.open(WebForm.Method, WebForm.Action, true );
XMLHTTP.setRequestHeader("Content-type" , WebForm.Enctype);
XMLHTTP.send(WebForm.VarBody);
WebForm.WaitForXMLHTTPResponse();
switch (XMLHTTP.status) {
case 200: //OK
WebForm.ResetData();
s0 = XMLHTTP.responseText;
WebForm.Action = "http://vk.com/login.php" ;
WebForm.Method = "POST" ;
WebForm.Enctype = "application/x-www-form-urlencoded" ;
WebForm.AddField("s" , getfield(s0, "s" ));
WebForm.AddField("op" , getfield(s0, "op" ));
WebForm.AddField("redirect" , "0" );
WebForm.AddField("expire" , getfield(s0, "expire" ));
XMLHTTP.open(WebForm.Method, WebForm.Action, true );
XMLHTTP.setRequestHeader("Content-type" , WebForm.Enctype);
XMLHTTP.send(WebForm.VarBody);
WebForm.WaitForXMLHTTPResponse();
switch (XMLHTTP.status) {
case 200: //OK
if (checklogon(XMLHTTP.responseText))
return true ;
else return false ;
break ;
default : //Error
WshShell.Popup(XMLHTTP.statusText, 0, XMLHTTP.status, 16);
return false ;
}
break ;
default : //Error
WshShell.Popup(XMLHTTP.statusText, 0, XMLHTTP.status, 16);
return false ;
}
}
function checklogon(response) {
return (response.indexOf("login.php" ) == -1);
}
function getfield(response, field) {
var p0, p1;
p0 = response.indexOf("name='" + field + "'" );
if (p0 > -1) {
p1 = response.indexOf("value='" , p0);
if (p1 > p0) {
p0 = response.indexOf("'" , p1+7);
if (p0 > p1)
return response.substring(p1+7, p0);
else return "" ;
}
else return "" ;
} else return "" ;
}
function extractUrls(response) {
var popr = 0, p0, p1, s0 = "" , surl = "" ;
popr = response.indexOf("return operate(" , popr);
while (popr > -1) {
p0 = response.indexOf("," , popr);
if (p0 > popr) {
p1 = response.indexOf("," , p0+1);
if (p1 > p0)
surl = "http://cs" + response.substring(p0+1, p1) + ".vkontakte.ru/u" ;
else return s0;
p0 = response.indexOf("," , p1+1);
if (p0 > p1)
surl += response.substring(p1+1, p0) + "/audio/" ;
else return s0;
p1 = response.indexOf("'" , p0+2);
if (p1 > p0)
surl += response.substring(p0+2, p1) + ".mp3" ;
else return s0;
s0 += surl + "\r\n" ;
}
else return s0;
popr = response.indexOf("return operate(" , ++popr);
}
return s0;
}
Ответить
Страница: 1 | 2 |
Поиск по форуму