Solved

Programmatically logging into a site, using a FORM POST

Posted on 2003-11-06
2
682 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio search word table and return Cell index 8 74
Visual Studio 2005 text editor 10 48
Recommendation vb6 to vb.net or others 14 201
vbModal 12 66
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

713 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