Retrieve Web data login/Password

Gregfox

Board Regular
Joined
Apr 12, 2011
Messages
120
Hello all, I’m trying to use vba to retrieve data from the following web site;
https://www.smithbarney.com/cgi-bin/login/login.cgi
I’m using Excel 2007 and the code I have so far is…
Rich (BB code):
Sub WebLogin()
Dim a As String
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "https://www.smithbarney.com/cgi-bin/login/login.cgi"
Do Until .readyState = 4
DoEvents
Loop
.document.all.Item("username").Value = "MyUserId"
.document.all.Item("password").Value = "MyPassword"
.document.forms(0).submit
End With
End Sub
I went to the web page and clicked view source, but couldn’t determine which login and password I should put in the code. I think the problem is username and password not matching the source code.
Once I login to the web page I would like to import a page, then logout and close the page.
Thanks, Any help would be most appreciated.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I'm not 100% certain but it looks like the username and password boxes are both called the same and they're doing something tricky with them - swapping them around, maybe... possibly it's a security measure to prevent people trying to run login scripts.

It's got me beat. :confused:
 
Upvote 0
<!--< span class="input">< input type="text" title="Enter Password" id="password" name="password" value="Enter Password" onblur= "checkCopy(this)" onfocus='swapfield(this,"password")' onkeyup="return handleEnterSubmission( this.form , event)" maxlength="35" autocomplete="off" />< /span>-->
<!--< span class="input">< input type="text" title="Enter Password" id="password" name="password" value="Enter Password" onblur= "checkCopy(this)" onkeydown='swapfield(this,"password")' *******='swapfield(this,"password")' onkeyup="return handleEnterSubmission(this.form,event)" maxlength="16" autocomplete="off" />< /span>-->
Joneye, did you look at the HTML?

HTML:
<!--< span class="input">< input type="text" title="Enter Password" id="password" 
name="password" value="Enter Password" onblur= "checkCopy(this)" 
onfocus='swapfield(this,"password")' 
onkeyup="return handleEnterSubmission( this.form , event)"  maxlength="35" 
autocomplete="off" />< /span>-->

<!--< span class="input">< input type="text" title="Enter Password" id="password" 
name="password" value="Enter Password" onblur= "checkCopy(this)" 
onkeydown='swapfield(this,"password")' *******='swapfield(this,"password")' 
onkeyup="return handleEnterSubmission(this.form,event)"  maxlength="16" 
autocomplete="off"  />< /span>-->
       
<!--< span class="input">< input type="text" title="Enter Password" id="password" 
name="password" value="Enter Password" onblur= "checkCopy(this)" 
onkeypress='swapfield(this,"password")' *******='swapfield(this,"password")' 
onkeyup="return handleEnterSubmission(this.form,event)"  maxlength="16" 
autocomplete="off"  />< /span>-->
 
< span class="input">< input type="text" title="Enter Password" id="password" 
name="password" value="Enter Password" onblur= "checkCopy(this)" 
onfocus='swapfield(this,"password")' onkeypress='swapfield(this,"password")' 
*******='swapfield(this,"password")' 
onkeyup="return handleEnterSubmission(this.form,event)"  maxlength="16" 
autocomplete="off"  />< /span>
I can't work out where the username is meant to go. I think the JavaScript is doing something cunning with the password, swapping it with the username 'somehow'.
 
Upvote 0
Hi there it work ok for me I did the tutorial first so I could get to grips with it
 
Upvote 0
Okay, that's good news. Perhaps the OP will be able to get it working then.
 
Upvote 0
Ruddles

Sorry to ask but is the script for the swapfield function on the page?

Can't view the source from here.:)
 
Upvote 0
I can't see it. I think it's dragged in here somewhere:-
HTML:
< script src="/js/new/login.js" type="text/javascript">< /script>
< script src="/js/new/CoreCookies.js" type="text/javascript">< /script>
< script language="JavaScript" src="/js/new/check_cbol_and_host.js">< /script>
< script type="text/javascript" src="/js/finger_print.js">< /script>
< script type="text/javascript" src="/js/leave_access.js">< /script>
< script type="text/javascript" src="/js/mwatchDivPosition.js">< /script>
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,153
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top