|
You last visited: Today at 02:53
Advertisement
Darkorbit - Vb 2010 - Login
Discussion on Darkorbit - Vb 2010 - Login within the DarkOrbit forum part of the Browsergames category.
02/18/2017, 23:01
|
#1
|
elite*gold: 0
Join Date: Jul 2015
Posts: 13
Received Thanks: 1
|
Darkorbit - Vb 2010 - Login
Hi guys.
At first sorry for my english.
I want to share my login code for Darkorbit in Visual Studio 2010.
You will need:
2x - TextBox
1x - Button
1x - WebBrowser
When form load it navigate webbrowser to darkorbit. -
Quote:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://www.darkorbit.com")
End Sub
|
This ll login you to darkorbit bot when you write username and password into TextBoxes.
Quote:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("bgcdw_login_f orm_username").SetAttribute("Value", TextBox1.Text)
WebBrowser1.Document.GetElementById("bgcdw_login_f orm_password").SetAttribute("Value", TextBox2.Text)
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In allelements
If webpageelement.GetAttribute("value") = "Login" Then
webpageelement.InvokeMember("click")
End If
Next
End Sub
|
IF YOU WANT ANY UPGRADES OR BETTER THINGS LIKE SKYLAB, AUCTION, ETC JUST TELL ME:-)
|
|
|
02/18/2017, 23:13
|
#2
|
elite*gold: 0
Join Date: May 2011
Posts: 1,764
Received Thanks: 1,577
|
This shouldnt be here but in the coding section.
Correct me if im wrong...
|
|
|
02/18/2017, 23:20
|
#3
|
elite*gold: 0
Join Date: Jul 2015
Posts: 13
Received Thanks: 1
|
Ye you are right. i missed :-D
Im actually new so.
|
|
|
02/19/2017, 01:01
|
#4
|
elite*gold: 0
Join Date: Aug 2015
Posts: 803
Received Thanks: 1,359
|
Thanks for sharing, but why do you use **** webbrowser? Use WebRequests.
|
|
|
02/19/2017, 02:41
|
#5
|
elite*gold: 93
Join Date: Oct 2012
Posts: 1,234
Received Thanks: 1,116
|
Quote:
Originally Posted by ramicek43
Hi guys.
At first sorry for my english.
I want to:
|
Sharing too!
Code:
public string login(string username, string pass)
{
try
{
this.STrequest("http://darkorbit.com");
string sMain = this.getResponse();
string url = this.find_str_from_to2(sMain, "\"bgcdw_login_form\" action=\"", "\">").Replace("&", "&");
this.STrequest(url);
this.request.Method = "POST";
this.setCookie();
byte[] bytes = Encoding.UTF8.GetBytes(string.Format("username={0}&password={1}", username, pass));
this.request.ContentLength = bytes.Length;
this.request.AllowAutoRedirect = false;
this.request.ContentType = "application/x-www-form-urlencoded";
this.request.Referer = "http://www.darkorbit.com/";
Stream requestStream = this.request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
for (sMain = this.getResponse(); this.response.StatusCode == HttpStatusCode.Found; sMain = this.getResponse())
{
url = this.response.Headers["Location"];
if (url.Equals("/indexInternal.es?action=internalStart"))
{
break;
}
this.setCookie();
this.STrequest(url);
this.request.AllowAutoRedirect = false;
}
if (url.StartsWith("http"))
{
return "wrong";
}
url = "http://" + this.request.Host + url;
this.STrequest(url);
this.setCookie();
sMain = this.getResponse();
string str4 = this.find_str_from_to2(sMain, "dosid=", "');");
string str3 = this.find_str_from_to2(sMain, "<link rel=\"meta\" href=\"http://", ".darkorbit.");
this.Session_ID = str4;
this.Session_server = str3;
return str4;
}
catch (WebException exception1)
{
ProjectData.SetProjectError(exception1);
WebException exception = exception1;
MessageBox.Show(exception.Message, "Http error");
ProjectData.ClearProjectError();
}
return null;
}
private void STrequest(string url)
{
this.request = (HttpWebRequest) WebRequest.Create(url);
this.request.Method = "GET";
this.request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
this.request.Headers.Add("Accept-Language", "en,en_EN;q=0.9,en;q=0.8");
this.request.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1");
this.request.Headers.Add("Accept-Encoding", "deflate, gzip, x-gzip, identity, *;q=0");
}
private string find_str_from_to2(string sMain, string sFrom, string sTo)
{
int index = sMain.IndexOf(sFrom);
if (index == -1)
{
return "-1";
}
index += sFrom.Length;
int num2 = sMain.IndexOf(sTo, index);
if (num2 == -1)
{
return "-1";
}
return sMain.Substring(index, num2 - index);
}
private string find_str_from_to2(string sMain, string sFrom, string sTo)
{
int index = sMain.IndexOf(sFrom);
if (index == -1)
{
return "-1";
}
index += sFrom.Length;
int num2 = sMain.IndexOf(sTo, index);
if (num2 == -1)
{
return "-1";
}
return sMain.Substring(index, num2 - index);
}
private void STrequest(string url)
{
this.request = (HttpWebRequest) WebRequest.Create(url);
this.request.Method = "GET";
this.request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
this.request.Headers.Add("Accept-Language", "en,en_EN;q=0.9,en;q=0.8");
this.request.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1");
this.request.Headers.Add("Accept-Encoding", "deflate, gzip, x-gzip, identity, *;q=0");
}
|
|
|
02/19/2017, 12:08
|
#6
|
elite*gold: 0
Join Date: Aug 2015
Posts: 803
Received Thanks: 1,359
|
Quote:
Originally Posted by ~Demetrio~
Sharing too!
Code:
public string login(string username, string pass)
{
try
{
this.STrequest("http://darkorbit.com");
string sMain = this.getResponse();
string url = this.find_str_from_to2(sMain, "\"bgcdw_login_form\" action=\"", "\">").Replace("&", "&");
this.STrequest(url);
this.request.Method = "POST";
this.setCookie();
byte[] bytes = Encoding.UTF8.GetBytes(string.Format("username={0}&password={1}", username, pass));
this.request.ContentLength = bytes.Length;
this.request.AllowAutoRedirect = false;
this.request.ContentType = "application/x-www-form-urlencoded";
this.request.Referer = "http://www.darkorbit.com/";
Stream requestStream = this.request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
for (sMain = this.getResponse(); this.response.StatusCode == HttpStatusCode.Found; sMain = this.getResponse())
{
url = this.response.Headers["Location"];
if (url.Equals("/indexInternal.es?action=internalStart"))
{
break;
}
this.setCookie();
this.STrequest(url);
this.request.AllowAutoRedirect = false;
}
if (url.StartsWith("http"))
{
return "wrong";
}
url = "http://" + this.request.Host + url;
this.STrequest(url);
this.setCookie();
sMain = this.getResponse();
string str4 = this.find_str_from_to2(sMain, "dosid=", "');");
string str3 = this.find_str_from_to2(sMain, "<link rel=\"meta\" href=\"http://", ".darkorbit.");
this.Session_ID = str4;
this.Session_server = str3;
return str4;
}
catch (WebException exception1)
{
ProjectData.SetProjectError(exception1);
WebException exception = exception1;
MessageBox.Show(exception.Message, "Http error");
ProjectData.ClearProjectError();
}
return null;
}
private void STrequest(string url)
{
this.request = (HttpWebRequest) WebRequest.Create(url);
this.request.Method = "GET";
this.request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
this.request.Headers.Add("Accept-Language", "en,en_EN;q=0.9,en;q=0.8");
this.request.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1");
this.request.Headers.Add("Accept-Encoding", "deflate, gzip, x-gzip, identity, *;q=0");
}
private string find_str_from_to2(string sMain, string sFrom, string sTo)
{
int index = sMain.IndexOf(sFrom);
if (index == -1)
{
return "-1";
}
index += sFrom.Length;
int num2 = sMain.IndexOf(sTo, index);
if (num2 == -1)
{
return "-1";
}
return sMain.Substring(index, num2 - index);
}
private string find_str_from_to2(string sMain, string sFrom, string sTo)
{
int index = sMain.IndexOf(sFrom);
if (index == -1)
{
return "-1";
}
index += sFrom.Length;
int num2 = sMain.IndexOf(sTo, index);
if (num2 == -1)
{
return "-1";
}
return sMain.Substring(index, num2 - index);
}
private void STrequest(string url)
{
this.request = (HttpWebRequest) WebRequest.Create(url);
this.request.Method = "GET";
this.request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
this.request.Headers.Add("Accept-Language", "en,en_EN;q=0.9,en;q=0.8");
this.request.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1");
this.request.Headers.Add("Accept-Encoding", "deflate, gzip, x-gzip, identity, *;q=0");
}
|
Code:
if (url.StartsWith("http"))
{
return "wrong";
}
Why not just throw an exception after login error? Or put an event like OnLoginFailure. Also I think Regex would be better solution in find_str_from_to2.
Edit:
why do you use this.? It's not Java.
Code:
if (url.Equals("/indexInternal.es?action=internalStart"))
Use == operator.
Please improve your code using by tips.
|
|
|
02/19/2017, 12:20
|
#7
|
elite*gold: 0
Join Date: Jul 2015
Posts: 13
Received Thanks: 1
|
Nver used WebRequest
i Thought that is more easy for begginers.
|
|
|
02/19/2017, 17:45
|
#8
|
elite*gold: 93
Join Date: Oct 2012
Posts: 1,234
Received Thanks: 1,116
|
Quote:
Originally Posted by Freshek
Code:
if (url.StartsWith("http"))
{
return "wrong";
}
Why not just throw an exception after login error? Or put an event like OnLoginFailure. Also I think Regex would be better solution in find_str_from_to2.
Edit:
why do you use this.? It's not Java.
Code:
if (url.Equals("/indexInternal.es?action=internalStart"))
Use == operator.
Please improve your code using by tips. 
|
HAHAHAHA always Criticizing another jobs!
since is not my code i don't care , it's reflector. i just wanted to help to him.
|
|
|
02/19/2017, 18:11
|
#9
|
elite*gold: 0
Join Date: May 2014
Posts: 663
Received Thanks: 1,154
|
Quote:
Originally Posted by Freshek
Code:
if (url.StartsWith("http"))
{
return "wrong";
}
Why not just throw an exception after login error? Or put an event like OnLoginFailure. Also I think Regex would be better solution in find_str_from_to2.
Edit:
why do you use this.? It's not Java.
Code:
if (url.Equals("/indexInternal.es?action=internalStart"))
Use == operator.
Please improve your code using by tips. 
|
Why you talking **** about other's code? It's as easy as ignoring the thread when you see in the name vb 2010
|
|
|
02/19/2017, 18:37
|
#10
|
elite*gold: 0
Join Date: Nov 2015
Posts: 157
Received Thanks: 61
|
Code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://www.darkorbit.com/")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
WebBrowser1.Document.GetElementById("bgcdw_login_form_username").SetAttribute("value", textbox1.Text)
WebBrowser1.Document.GetElementById("bgcdw_login_form_password").SetAttribute("value", textbox2.Text)
For Each p As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If p.GetAttribute("type") = "submit" Then
p.InvokeMember("click")
End If
Next
Catch ex As Exception
MsgBox("Error: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
End Class
|
|
|
02/19/2017, 19:10
|
#11
|
elite*gold: 0
Join Date: Aug 2015
Posts: 803
Received Thanks: 1,359
|
Quote:
Originally Posted by manulaiko3.0
Why you talking **** about other's code? It's as easy as ignoring the thread when you see in the name vb 2010
|
Someone might just use this code in his project. I just gave him few tips how can he improve it. What's bad in it?
|
|
|
02/20/2017, 00:00
|
#12
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
Quote:
Originally Posted by jorg*
This shouldnt be here but in the coding section.
Correct me if im wrong...
|
This thread should not exist in any ssection
Quote:
Originally Posted by Freshek
Why not just throw an exception after login error? Or put an event like OnLoginFailure. Also I think Regex would be better solution in find_str_from_to2.
Edit:
why do you use this.? It's not Java.
Code:
if (url.Equals("/indexInternal.es?action=internalStart"))
Use == operator.
Please improve your code using by tips. 
|
I feel the abuse of event's here.
Also this url.Equals might be some weird compiler optimisation or just his crappy decompiler.
There are valid use cases to not use the == operator
Quote:
Originally Posted by ramicek43
SNIP
|
I also want to share some knowledge with you
Visual Basic is the programming language.
Visual Studio is the "IDE".
2010 is the edition of this "IDE".
It's not VB 2010. It is Visual Basic code produced in Visual Studio 2010 and probably you are compiling with the Visual Basic .Net 3.5 compiler
Quote:
Originally Posted by Freshek
Someone might just use this code in his project. I just gave him few tips how can he improve it. What's bad in it?
|
No one should ever use ANY code provided in this thread
|
|
|
02/20/2017, 18:18
|
#13
|
elite*gold: 0
Join Date: Jul 2015
Posts: 13
Received Thanks: 1
|
Whats going on here..
i just tried to help begginers in VB
It is the most simple way i think so.
|
|
|
02/20/2017, 19:27
|
#14
|
elite*gold: 0
Join Date: May 2014
Posts: 663
Received Thanks: 1,154
|
Quote:
Originally Posted by ramicek43
Whats going on here..
i just tried to help begginers in VB
It is the most simple way i think so.
|
You did nothing wrong, is just that there are people that whatever you do, they will try to find a flaw on it and tell you a better way.
When coding it's more obvious, not only in this section, but everywhere. Have you ever seen someone talk **** about a programming language? Generally Java is most hated one, Saying that java is nice because it works on all platforms is like saying that **** *** is fine because it works on all genres or I hate java because it's ******* slow, stupid ****, how many people do you think that actually hate a language because they have their own reason? 5? maybe 6? Rest are just talking **** because someone smarter than them said it so they try to look smarter. Me for example, I hate C# because of Micro$oft and its stupid one-line fixers that only leads to spaghetti code, yes, just for that, the rest is an over actuation of myself trying to look smarter because I try to point fails at someone else.
That's basically how the thing works here (or anywhere else). Once you see things like this you should ignore it and keep doing what you think it's the best.
|
|
|
02/21/2017, 12:13
|
#15
|
elite*gold: 0
Join Date: Jul 2015
Posts: 13
Received Thanks: 1
|
Quote:
Originally Posted by manulaiko3.0
You did nothing wrong, is just that there are people that whatever you do, they will try to find a flaw on it and tell you a better way.
When coding it's more obvious, not only in this section, but everywhere. Have you ever seen someone talk **** about a programming language? Generally Java is most hated one, Saying that java is nice because it works on all platforms is like saying that **** *** is fine because it works on all genres or I hate java because it's ******* slow, stupid ****, how many people do you think that actually hate a language because they have their own reason? 5? maybe 6? Rest are just talking **** because someone smarter than them said it so they try to look smarter. Me for example, I hate C# because of Micro$oft and its stupid one-line fixers that only leads to spaghetti code, yes, just for that, the rest is an over actuation of myself trying to look smarter because I try to point fails at someone else.
That's basically how the thing works here (or anywhere else). Once you see things like this you should ignore it and keep doing what you think it's the best.
|
yep i can see that..
I`m going to ignore them:-D
And the reason why I'm posting this is because i want to create dark orbit bot that do everything and this is CORE if someone want 2.
Everything means- betting on auction, skylab, upgrades and etc. I can do everything except Killing npc, boxing and etc.. I'm trying to find easy way like it is in CANDY BOT.
Still nothing so if someone have advice for me.
Would be great.
And again sorry for my english
|
|
|
All times are GMT +1. The time now is 02:54.
|
|