I trying to login using a webbrowser in vb.net with the following:
Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("username").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("password").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById("ID_HERE").InvokeMember("click")
End Sub
However, I can't find the ID/Name of the Submit/Login button.
However, I can't find the ID/Name of the Submit/Login button.
Website:
Somebody able to help me out?
Thanks in advance
That's because the submit button has no id assigned to it.
I don't know if you can use XPath with your Browser control but if you can then just learn some basics about XPath and get the submit button with its XPath.
If you can't use XPath then you could try to execute some piece of Javascript to get and click the submit button.
If the button has a unique class-name you can do this:
Code:
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If element.GetAttribute("className") = "THE_CLASS_NAME" Then
element.invokeMember("click")
End If
Next
But of course, WebRequests are much better.
edit: The className seems to be bgcdw_button bgcdw_login_form_login
I've tried it and it worked
If the button has a unique class-name you can do this:
Code:
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If element.GetAttribute("className") = "THE_CLASS_NAME" Then
element.invokeMember("click")
End If
Next
But of course, WebRequests are much better.
edit: The className seems to be bgcdw_button bgcdw_login_form_login
I've tried it and it worked
You could do this but a class is not unique by nature it might work in this case but I would generally not rely on this even if a class appears to be unique.
If the button has a unique class-name you can do this:
Code:
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If element.GetAttribute("className") = "THE_CLASS_NAME" Then
element.invokeMember("click")
End If
Next
But of course, WebRequests are much better.
edit: The className seems to be bgcdw_button bgcdw_login_form_login
I've tried it and it worked
Thanks! I'll maybe gonna use this, but first I try to use webrequests for now.
EDIT: Working with the webrequests now, can't find the right referer for Seafight login.
Found this but doesn't seem to work:
Code:
Dim postData As String = "referer=http%253A%252F%252Fwww." & NsTextBox3.Text & ".seafight.bigpoint.com%252Fusername%253D" & NsTextBox1.Text & "%2526password%253D" & NsTextBox2.Text
NsTextbox1.Text contains the Username
NsTextbox2.Text contains the Password
NsTextbox3.Text contains the server shortcut (ex. int1)
Dim logincookie As CookieContainer
Private Sub NsButton1_Click(sender As Object, e As EventArgs) Handles NsButton1.Click
Dim postData As String = "referer=http%253A%252F%252Fwww." & NsTextBox3.Text & ".seafight.bigpoint.com%252Fusername%253D" & NsTextBox1.Text & "%2526password%253D" & NsTextBox2.Text
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://" & NsTextBox3.Text & ".seafight.bigpoint.com/index.es?action=internalHome&loginDone=true"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www.form.urlencoded"
postReq.Referer = "http://" & NsTextBox3.Text & ".seafight.bigpoint.com/index.es?action=internalHome&loginDone=true"
postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
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)
tempCookies.Add(postresponse.Cookies)
logincookie = tempCookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
RichTextBox1.Text = thepage
End Sub
However, It seems the HTTP header isn't the right one and I can't seem to find the right one with LiveHTTPHeader or Fiddler, any tips to find the right one?
[Question]Disable Confirm Button and Enable Submit 11/14/2014 - Shaiya PServer Development - 14 Replies Hello everyone today i come to you all to let you know that i have successfully enabled the 'OK' Button when attempting to do a transaction on a game.exe ep 5.4 - 6 . It took me days and maybe even a week to figure this out LOL. But i would like to get the opinions of the REAL FEW developers and coders of this community. Would it be something you guys would like me to do a tutorial about it or just simply give address and things to change on those addresses?. Or maybe would it b something that...
Homepage Submit Button! 04/29/2012 - Flyff Private Server - 3 Replies Guten Tag, ich wollte mal Fragen ob es so funktionieren kann wie ich es umgeschrieben habe.
Es geht um ein weiteres Donate Script wo ich halt mit dem PayPal donate Button es absenden kann.
Hier ist es vom Paysafe:
<input type="submit" name="psc_sbm" value="Donate Now" />
Und so habe ich es im Paypal Script geschrieben:
<form action="https://www.paypal.com/cgi-bin/webscr " method="post">
PHP: Submit Button und Eintrag in Log 04/16/2012 - Web Development - 3 Replies Hallo,
wie kann ich nach einem Klick auf einen Submit-Button gleichzeitig einen Eintrag in einer .txt Datei machen, mit dem Inhalt der Variablen $settings, $userdata und $userdata?
Mein Script soll den Submit Button drücken 11/27/2011 - AutoIt - 8 Replies Hallo Jungs,
habe seit längerem ein Script vor, das ich gestern endlich richtig angefangen habe. Es soll mir auf einer Webseite automatisch Gästebucheinträge schreiben.
Habe es selber soweit geschafft, dass er eine Seite aufmacht und ins Gästebuch schreibt. Leider schaff ich es nicht, dass er es abschickt bzw. den Submit Button drückt. Habe gestern Nacht alles probiert, bis ich wirklich Kopfschmerzen bekommen habe.
Über Hilfe wäre ich sehr dankbar, am besten mit TS3 oder so, da ich die...
2 Submit Button ein Problem 03/17/2011 - AutoIt - 2 Replies Hallo AutoItler,
ich möchte den Submit Button name="start" anklicken weiß aber nich wie ich das machen soll habs schon mit _IEFormSubmit() und _IEAction() probiert aber es funktioniert nicht.
Und hier der Quelltext: Ich möchte den Submit Button name="start" anklicken.
<form name='arena' id='arena' action='/bg/arena.php' method='post'>
<input type='hidden' name='__token' value='57c6bb5cdb0a6782a9bc18362cc67402' />
<input type="submit" name="start" value="Kampf starten" /><br /><br />
...