Solved

Programmatically logging into a site, using a FORM POST

Posted on 2003-11-06
2
678 Views
Last Modified: 2008-02-01
I'm trying to create an Internet Explorer instance which will login to Yahoo Groups programmatically.  Below is what I have.  Where {username} is a valid username, and {password} is the associated, valid password.  The final product should be an open instance of Internet Explorer displaying all my Yahoo Groups.

'--------------------------------------------

Dim obIE As SHDocVw.InternetExplorer
   
Set obIE = New SHDocVw.InternetExplorer
   
Call obIE.Navigate2("https://login.yahoo.com/config/login?.intl=us&.src=ygrp&.done=http://groups.yahoo.com%2F", , , "login={username}&password={password}")
   
Do Until obIE.readyState = READYSTATE_COMPLETE
    DoEvents
Loop

Call obIE.Navigate2("http://groups.yahoo.com/mygroups")
   
Do Until obIE.readyState = READYSTATE_COMPLETE
    DoEvents
Loop

obIE.Visible = True

'--------------------------------------------

Thank you in advance.
0
Comment
Question by:jessy_houle
2 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 500 total points
ID: 9699236
Hi Jessy_Houle, I made a piece of code which will exactly do your thing.

Private Sub Form_Load()
    Dim ITEM As Variant
    Dim obIE As SHDocVw.InternetExplorer
    Dim obDC As HTMLDocument

    Set obIE = New SHDocVw.InternetExplorer
        obIE.Navigate "http://groups.yahoo.com/mygroups"
        obIE.Visible = True
  While obIE.Busy: DoEvents: Wend

    Set obDC = obIE.Document
    Do Until obDC.readyState = "complete"
        DoEvents
    Loop
   
    For Each ITEM In obDC.All.tags("input")
        'Fill in the username textbox
        If ITEM.Name = "login" Then ITEM.Value = "MyUsername"
        'Fill in the password textbox
        If ITEM.Name = "passwd" Then ITEM.Value = "MyPass"
    Next
   
    'Check the remember me checkbox if you wish
        obDC.All.ITEM(".persistent").Click
    'Click on Sign in
        obDC.All.ITEM(".Save").Click
        While obIE.Busy: DoEvents: Wend
End Sub

Happy programming,
Ayhan Elatik
0
 

Author Comment

by:jessy_houle
ID: 9701900
aelatik:

Great Job!  Thank you very much.  The reason that I need this in the first place is because of the ".persistent" issue.  My entire family uses the same computer (and NT User account), and each of us has different My Yahoo Groups.  If I check the persistent checkbox, then my wife and children will default to my groups, and vice versa.  This way, I can display a simple VB form to choose the person, and it will pop up their associated My Yahoo Groups page.

Thanks again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now