I can't figure out how to log in to the website in the title and retrieve the amount of points the user has. Any help would be extremely greatful.
Printable View
I can't figure out how to log in to the website in the title and retrieve the amount of points the user has. Any help would be extremely greatful.
Hai Hvk,
Here the example code for yahoo auto login, just replace the corresponding url and elements such as username, passwd and login button.
vb Code:
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Part 1: Load Yahoo login page in Form_Load event WebBrowser1.Navigate("https://login.yahoo.com/") End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted 'Part 2: Locate the Username TextBox and automatically input your username '<INPUT class=yreg_ipt id=username maxLength=96 size=17 name=login> Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input") For Each curElement As HtmlElement In theElementCollection Dim controlName As String = curElement.GetAttribute("id").ToString If controlName = "username" Then curElement.SetAttribute("Value", "your username") End If Next 'Part 3: Locate the Password TextBox and automatically input your password '<INPUT class=yreg_ipt id=passwd type=password maxLength=64 size=17 value="" name=passwd> theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input") For Each curElement As HtmlElement In theElementCollection Dim controlName As String = curElement.GetAttribute("id").ToString If controlName = "passwd" Then curElement.SetAttribute("Value", "your password") End If Next 'Part 4: Locate the "Sign In" Button and automatically click it '<INPUT type=submit value="Sign In" name=.save> theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input") For Each curElement As HtmlElement In theElementCollection If curElement.GetAttribute("value").Equals("Sign In") Then curElement.InvokeMember("click") 'Javascript has a click method for we need to invoke on the current submit button element. End If Next End Sub End Class
Thanks a bunch, but how to i go about using the document complete part of that code. It's confusing me a little bit :/ From what i read it is trying to find the username and password fields and insert your information into them but when i tried it it didnt exactly work :/ any help?
Add webbroswer control into your form and read the source of yourdomain.com and find the html element of username, password and login button and replace with above code!
So just replace the value part of the code? as well as my username and password? I've been messing with this for quite some time :/ can anyone here teamview me a guide me through this part?
I got it to automatically enter my information but i cant get it to sign in :/
page source:
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Welcome to Lockerz</title>
<meta name="description" content="LOCKERZ is a free membership site that offers original content, commerce and community for Generation Z."/>
<link rel="shortcut icon" href="http://static.lockerz.com/sites/default/themes/sky/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/sites/default/themes/sky/assets/css/base.css" type="text/css" />
<link rel="stylesheet" href="sites/default/themes/sky/assets/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="sites/default/themes/sky/assets/css/section-login.css" type="text/css" media="screen" />
<!-- notes
please call these functions when their respected events take place events.....
passwordAccepted()
wrongEmail()
wrongPassword()
-->
<script src="http://static.lockerz.com/sites/default/themes/sky/assets/scripts/swfobject.js" type="text/javascript"></script>
<script src="http://static.lockerz.com/sites/default/themes/sky/assets/scripts/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="http://static.lockerz.com/sites/default/themes/sky/assets/scripts/globalFunctions.js" type="text/javascript"></script>
</head>
<body onLoad=" MM_preloadImages('http://static.lockerz.com/sites/default/themes/sky/assets/img/login/signInDown.png','http://static.lockerz.com/sites/default/themes/sky/assets/img/login/signInOver.png','http://static.lockerz.com/sites/default/themes/sky/assets/img/footer/popUp-CoolBrands.png');">
<div id="holder">
<a href="/"><img id="logo" src="http://static.lockerz.com/sites/default/themes/sky/assets/img/login/logo.png" alt="Lockerz"/></a>
<div id="center">
<div id="contentHolder">
<div id="content">
<div id="left">
<img id="welcome" src="http://static.lockerz.com/sites/default/themes/sky/assets/img/login/welcome.png" alt="Welcome"/>
<!-- start block.tpl.php -->
<form action="/front_page?destination=front_page" accept-charset="UTF-8" method="post" id="user-login-form">
<div><div id="login">
<div class="leftSide"></div>
<div class="fieldHolder"><div class="form-item" id="edit-name-wrapper">
<label for="edit-name">Username or e-mail: <span class="form-required" title="This field is required.">*</span></label>
<input type="text" maxlength="60" name="name" id="edit-name" size="15" value="EMAIL" tabindex="1" class="form-text required field" onfocus="handleFocus(this)" onblur="handleUnfocus(this)" />
</div>
</div>
<div class="rightSide"></div>
</div><div id="pass">
<div class="leftSide"></div>
<div class="fieldHolder"><div class="form-item" id="edit-pass-wrapper">
<label for="edit-pass">Password: <span class="form-required" title="This field is required.">*</span></label>
<input type="password" name="pass" id="edit-pass" maxlength="60" size="15" tabindex="2" class="form-text required field" onfocus="handleFocus(this)" onblur="handleUnfocus(this)" />
</div>
</div>
<div class="rightSide"></div>
</div><div class="form-item" id="edit-remember-me-wrapper">
<label class="option" for="edit-remember-me"><input type="checkbox" name="remember_me" id="edit-remember-me" value="1" checked="checked" tabindex="3" class="form-checkbox" /> <p>Remember me</p></label>
</div>
<input type="submit" name="op" id="edit-submit" value="Log in" tabindex="3" class="form-submit user-login-button login-initial" />
<div class="item-list"><ul><li class="first"><a href="/user/register" title="Create a new user account.">Create new account</a></li>
<li class="last"><a href="/user/password" title="Request new password via e-mail.">Request new password</a></li>
</ul></div><input type="hidden" name="form_build_id" id="form-367cb3438745b3f053b91d2cb3bc2425" value="form-367cb3438745b3f053b91d2cb3bc2425" />
<input type="hidden" name="form_id" id="edit-user-login-block" value="user_login_block" />
</div></form>
<!-- end block.tpl.php --> <a href="/forgot"><img id="forgot" src="http://static.lockerz.com/sites/default/themes/sky/assets/img/login/forgot.png" alt="Forgot your combination? Hint: It's your password. -->"/></a>
<a href="/nonmember"><img id="new" src="http://static.lockerz.com/sites/default/themes/sky/assets/img/login/notMember.png" alt="New to Lockerz? Get Invited -->"/></a>
</div><!-- left -->
<div id="right">
<div id="carousel">
<!-- content to get replaced by flash. -->
<div id="replaceByFlash"></div>
</div>
</div><!-- right -->
</div><!-- content -->
</div><!-- contentHolder -->
</div><!-- center -->
</div><!-- holder -->
<!-- FOOTER replace this with footer include -->
<div id="footer">
<img class="left" id="allThat" src="http://static.lockerz.com/sites/default/themes/sky/assets/img/footer/allThat.gif" width="151" height="14" alt="All That and More" onmouseover="window.showFooterPopUp();" onmouseout="window.hideFooterPopUp();"/>
<img id="coolBrands" src="http://static.lockerz.com/sites/default/themes/sky/assets/img/footer/popUp-CoolBrands.png" width="240" height="83" alt="Cool brands, music, and video:" />
<!-- FOOTER LINKS -->
<div id="footerLinks">
<a href="/feedback">Feedback</a>
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/common/pipe-DarkBKG.gif" class="footerPiping" />
<a href="/about">About</a>
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/common/pipe-DarkBKG.gif" class="footerPiping" />
<a href="/privacy">Privacy</a>
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/common/pipe-DarkBKG.gif" class="footerPiping" />
<a href="/terms">Terms</a>
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/common/pipe-DarkBKG.gif" class="footerPiping" />
<a href="/faq">FAQ</a>
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/common/pipe-DarkBKG.gif" class="footerPiping" />
<a href="/jobs">Jobs</a>
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/common/pipe-DarkBKG.gif" class="footerPiping" />
<a href="/contact">Contact</a>
</div>
<!-- END FOOTER LINKS -->
</div>
<!-- END FOOTER -->
<script type="text/javascript" src="http://static.lockerz.com/sites/default/themes/sky/assets/scripts/login.js"></script>
<script type="text/javascript">
document.getElementById('edit-submit').value = '';
</script>
<script type="text/javascript">
var flashvars = {};
var params = {
wmode:"transparent",
base:"sites/default/themes/sky/assets/flash/"
};
var attributes = {
align:"top"
};
swfobject.embedSWF("sites/default/themes/sky/assets/flash/carousel.swf", "replaceByFlash", "412", "350", "8.0.0", "sites/default/themes/sky/assets/flash/expressInstall.swf", flashvars, params, attributes);
</script>
<!-- google-analytics -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-8356268-1"); pageTracker._trackPageview(); } catch(err) {}
</script>
<!-- google-analytics END-->
</body>
</html>
What am i missing?:
Code:Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
'Part 2: Locate the Username TextBox and automatically input your username
'<INPUT class=yreg_ipt id=username maxLength=96 size=17 name=login>
Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("id").ToString
If controlName = "edit-name" Then
curElement.SetAttribute("Value", "My Email")
End If
Next
'Part 3: Locate the Password TextBox and automatically input your password
'<INPUT class=yreg_ipt id=passwd type=password maxLength=64 size=17 value="" name=passwd>
theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("id").ToString
If controlName = "edit-pass" Then
curElement.SetAttribute("Value", "My password")
End If
Next
'Part 4: Locate the "Sign In" Button and automatically click it
'<INPUT type=submit value="Sign In" name=.save>
theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("value").Equals("Log in") Then
curElement.InvokeMember("submit")
'Javascript has a click method for we need to invoke on the current submit button element.
End If
Next
End Sub
Code:If controlName = "edit-pass" Then
I think, possibly, the control name should be "pass".Code:<input type="password" name="pass"
I'm not having trouble with that part of the code just the cubmit part or the pressing of the sign in button :/ This needs to be done by today! I'm freaking out. Any help?
Sorry to double post but i believe the submit button is javascript and as it says in this bit of code:
Code:For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("value").Equals("Log in") Then
curElement.InvokeMember("submit")
'Javascript has a click method for we need to invoke on the current submit button element.
End If
Next
End Sub
There is a different method for using javascript submitting. Does anyone know how to do that? I think that is my problem
i will provide an account i just set up for you
email = [email protected]
password = angela
If you could get that part working i would owe you big time! I've tried everything i know as well as looking up everything on google!
Thank you so much!
Here the code which you want:
vb Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WebBrowser1.Navigate("http://www.lockerz.com/") End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input") For Each curElement As HtmlElement In theElementCollection Dim controlName As String = curElement.GetAttribute("id").ToString If controlName = "edit-name" Then curElement.SetAttribute("Value", "[email protected]") End If Next 'Part 3: Locate the Password TextBox and automatically input your password '<INPUT class=yreg_ipt id=passwd type=password maxLength=64 size=17 value="" name=passwd> theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input") For Each curElement As HtmlElement In theElementCollection Dim controlName As String = curElement.GetAttribute("id").ToString If controlName = "edit-pass" Then curElement.SetAttribute("Value", "angela") End If Next 'Part 4: Locate the "Sign In" Button and automatically click it '<INPUT type=submit value="Sign In" name=.save> theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input") For Each curElement As HtmlElement In theElementCollection Console.WriteLine(curElement.Id) If curElement.Id.Equals("edit-submit") Then curElement.InvokeMember("click") 'Javascript has a click method for we need to invoke on the current submit button element. End If Next End Sub End Class
Works! Thank you so much!
One more question! Sorry to be so demanding! In the following code, how would i get the green text from the html and display it in a messages box?
Code:<div id="column1">
<img id="comingSoon" height="132" width="147" alt="Coming Soon" src="http://static.lockerz.com/sites/default/themes/sky/assets/img/myLocker/corner-GoForIt.png"/>
<div id="lockerLeft">
<div id="indentDark">
<div id="lockerDoor">
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/myLocker/btn-MyLocker.gif" width="162" height="41" alt="My Locker" style="margin-bottom:16px;" />
<div class="notification">
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/myLocker/icon-alerts.png" width="19" height="19" alt="Alerts" />
<div class="alertText">9 new alerts</div>
</div>
<div class="notification">
<a href="ptzboutique">
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/myLocker/icon-ptz.png" width="19" height="19" alt="Redeem" />
</a>
<div class="alertText">190 PTZ</div>
</div>
<div class="notification">
<a href="connect_landing">
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/myLocker/icon-friends.png" width="19" height="19" alt="Connect" />
</a>
<div class="alertText">8 friends joined</div>
</div>
<div class="notification">
<a href="#" onclick="launchPopup('zlistPopUp'); return false">
<img src="http://static.lockerz.com/sites/default/themes/sky/assets/img/myLocker/icon-Zlist.png" width="19" height="19" alt="Z-List" />
</a>
<a href="/sites/default/themes/sky/zlist.html" id="zlistPopUp" class="floatbox" data-fb-options="innerBorder:0 width:750 height:440 scrolling:no showClose:false onItemStart:onBoxStart()"></a>
<div class="alertText">8 accepted friends<br />12 to go</div>
</div>
</div>
This violates Lockerz.com's EULA, by the way.
Where exactly in the EULA do you find that this violates it agreement? I've looked through it and have found nothing. Provide evidence please
Oh it's fine i just don't want violate any EULA! I'm just trying to make it easier for users! If you find a violation please tell me. Thanks!
Try with regex...
Try this regex and choose the second match...
vb Code:
Dim pattern As String = "(?<=class=""alertText""\>).+(?=\<\/div\>)" Dim matches As MatchCollection = Regex.Matches(WebBrowser1.DocumentText, pattern) For Each m As Match In matches MessageBox.Show(m.Value) Next
I've checked their EULA, and it seems that this is fine - what would cause problems is altering the points in any way, just reading them seems to be valid.
If your problem solved, by using the thread tools change as "Resolved" :)