none
Yahoo Login Via System.Net.Sockets Namespace

    Question

  • I need help here I have a program I wrote years ago to login yahoo to send email and recently I tried to use and my logins were failing.  The problem is yahoo changed there login URL Structure.  If someone can reply with the correct one I will appreciate the help.  I have placed a peice of the code below.

    Dim LoginPacket As String

    LoginPacket = "GET http://login.yahoo.com/config?&login=" & txtLEmail.Text & "&passwd=" & strPass.Trim & " HTTP/1.0" & vbCrLf

    LoginPacket = LoginPacket & "Accept: */*" & vbCrLf

    LoginPacket = LoginPacket & "Accept: text/html" & vbCrLf & vbCrLf

    LoginPacket = LoginPacket

    wsTCP.Protocol = OSWINSCK.ProtocolConstants.sckTCPProtocol

    wsTCP.SendData(LoginPacket)

     

    Monday, November 3, 2008 8:27 PM

Answers

  • Charlieit123 said:

    I need help here I have a program I wrote years ago to login yahoo to send email and recently I tried to use and my logins were failing.  The problem is yahoo changed there login URL Structure.  If someone can reply with the correct one I will appreciate the help. 

    Hi Charlieit,

    I hope someone know the available Yahoo login URL Structure and tell you.

    However, instead you can use WebBrowser control to automatically login in Yahoo website.
    Firstly you need to know web elements(e.g. Username textbox, Password textbox and Sign In button) source html code via viewing source(Right-click on web page -> "View Source" menu item). The following code sample can login in Yahoo successfully. Please take it a try with your username and password.

    Prerequisites: Drag&drop WebBrowser1 onto Form1.

    Public Class Form1  
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal 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.ObjectByVal 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 

    Check these similar code samples for detailed instruction:
    1.
    Automatically login in one website (input uername/password and click Login button)
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2486275&SiteID=1

    2. Automatically Live search http://www.live.com/ (enter search keyword and click Search button)
    http://forums.msdn.microsoft.com/en-US/vbgeneral/thread/f06fcdca-ed9b-464b-ba08-edd26b0dc801/



    Additionally, .NET Framework Networking and Communication is here.


    Best regards,
    Martin Xie

    Monday, November 10, 2008 7:33 AM

All replies

  • Charlieit123 said:

    I need help here I have a program I wrote years ago to login yahoo to send email and recently I tried to use and my logins were failing.  The problem is yahoo changed there login URL Structure.  If someone can reply with the correct one I will appreciate the help. 

    Hi Charlieit,

    I hope someone know the available Yahoo login URL Structure and tell you.

    However, instead you can use WebBrowser control to automatically login in Yahoo website.
    Firstly you need to know web elements(e.g. Username textbox, Password textbox and Sign In button) source html code via viewing source(Right-click on web page -> "View Source" menu item). The following code sample can login in Yahoo successfully. Please take it a try with your username and password.

    Prerequisites: Drag&drop WebBrowser1 onto Form1.

    Public Class Form1  
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal 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.ObjectByVal 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 

    Check these similar code samples for detailed instruction:
    1.
    Automatically login in one website (input uername/password and click Login button)
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2486275&SiteID=1

    2. Automatically Live search http://www.live.com/ (enter search keyword and click Search button)
    http://forums.msdn.microsoft.com/en-US/vbgeneral/thread/f06fcdca-ed9b-464b-ba08-edd26b0dc801/



    Additionally, .NET Framework Networking and Communication is here.


    Best regards,
    Martin Xie

    Monday, November 10, 2008 7:33 AM
  • Dear Mr Martin Xie...

    I need your help to use the cookie after successfull login to yahoo.....

    I want this cookie in one more web request.... i.e finance.yahoo.com for real time financial data......

    I used your above code to login ....

    Please help me

    Thanks in Advance
    Sansharam
    Wednesday, November 4, 2009 6:31 PM
  • Dear Sansharam,

    Here are some tutorials for you to check:

    1. Thread "Using same cookies of a WebBrowser control in a WebRequest"
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/c8107e4d-fe8f-4be9-81a4-0575eb72248f/
    You can transfer the cookies like this: 

    Dim request As HttpWebRequest = CType(WebRequest.Create (myUri), HttpWebRequest)

    request.CookieContainer = New CookieContainer ()

    request.CookieContainer.SetCookies (myUri, webBrowser1.Document.Cookie)



    2. Play with HttpWebRequest class (which supports cookies)
    HttpWebRequest.CookieContainer Property
    http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.cookiecontainer.aspx


    3. Pop-up page lost session from WebBrowser
    http://social.msdn.microsoft.com/forums/en/vbgeneral/thread/1c7eba04-8899-4acc-9f88-b0402c6c27e6/



    Best regards,
    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, November 5, 2009 9:28 AM
  • Dear Mr Martin Xie

    Thanks for your support.

    I request you to look at this software "myQuotes" at volumedigger.com.

    He has made it possible - login to Yahoo! using httpget and httppost

    I could not able to understand how he has done it... please if you can .... please let me know


    Yes-- your solution is also is a good one but it takes resources and time to load the page and search tags, input id and again click login button, again load successful login page..... little time consuming and resource consuming

    Please have a look at the software given above... I hope you can solve it

    Thanks and Regards
    Sansharam
    Monday, December 7, 2009 11:59 AM
  • How would you click the button if it was javascript though :/ I'm using this code and everything works flawlessly but i can't seem to figure out how to click submit. It is javascript/. Any help?
    Thursday, December 17, 2009 8:54 PM
  • Hello,
    When I try to use the navigate command from a module, the webBrowser isn't udpating. Here is my code (I use VB .Net Express 2008):
      
    Public Class frmWeb

        Private Sub cmdShowWebPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdShowWebPage.Click

            getWebsite(txtURL.Text)

        End Sub

        Private Sub frmWeb_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            WebB.Navigate("http://www.google.co.uk/")
        End Sub
    End Class


    Module mdlWeb
        Sub getWebsite(ByVal URL As String)
            frmWeb.WebB.Navigate(URL)
            frmWeb.WebB.Update()


        End Sub
    End Module



    Please not that the page is correctly loaded at startup and if I put the code directly in the form code (in the click buton event), again teh code works without anyt problem. Only when I call the code from the module, no udpates are being made.

    Thank you for any help.
    Arnaud
    Tuesday, March 9, 2010 2:08 PM
  • Hi,

    i guess that you somehow using a incorrect url in your textbox.

    This works for me:


    'Visual Basic 2008 - .net 3.5 - Any CPU
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            getWebsite("www.google.co.uk")
        End Sub
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            WebB.Navigate("http://www.google.co.uk/")
        End Sub
    End Class
    Module mdlWeb
        Sub getWebsite(ByVal URL As String)
            Form1.WebB.Navigate(URL)
            Form1.WebB.Update()
        End Sub
    End Module
    


    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    Tuesday, March 9, 2010 2:28 PM
  • Hello Charlieit123,

     

    Considering that many developers in this forum ask how to automate a web page via WebBrowser, rotate or flip images, my team has created a code sample for this frequently asked programming task in Microsoft All-In-One Code Framework. You can download the code samples at:

     

    VBWebBrowserAutomation

     

    http://bit.ly/VBWebBrowserAutomation

     

    CSWebBrowserAutomation

     

    http://bit.ly/CSWebBrowserAutomation

     

    With these code samples, we hope to reduce developers’ efforts in solving the frequently asked

    programming tasks. If you have any feedback or suggestions for the code samples, please email us: onecode@microsoft.com.

    ------------

    The Microsoft All-In-One Code Framework (http://1code.codeplex.com) is a free, centralized code sample library driven by developers' needs. Our goal is to provide typical code samples for all Microsoft development technologies, and reduce developers' efforts in solving typical programming tasks.

    Our team listens to developers’ pains in MSDN forums, social media and various developer communities. We write code samples based on developers’ frequently asked programming tasks, and allow developers to download them with a short code sample publishing cycle. Additionally, our team offers a free code sample request service. This service is a proactive way for our developer community to obtain code samples for certain programming tasks directly from Microsoft.

    Thanks

    Microsoft All-In-One Code Framework

    Thursday, March 24, 2011 10:23 AM
  •  hello Martin

    i used your code but it doesn't work because yahoo change their html design.

    i look at the html code and i see that the <input type="submit .... changed to

     

           <div id='submit'>
                <button type='submit' id='.save' name='.save' class='primaryCta' tabindex='5'>
                  Sign In
                </button>	        </div>

     

    i change your code to

     

        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", "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", "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("button")
            For Each curElement As HtmlElement In theElementCollection
                If curElement.GetAttribute("value").Equals(".save") 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
    

    but it doesn't work agian.what is problem?

     

     

     

     

    Monday, September 12, 2011 7:19 AM
  • 1)download OSWINSCK.DLL (http://www.ostrosoft.com/download/oswinsck.zip) 2)unzip oswinsck and copy oswinsck.dll in system32 folder(c:\windows\system32\) 3)goto [start menu]->[Run menu] 4)run this command : regsvr32 OSWINSCK.dll 5)goto to visual studio 2005 or ... 6)create a windows application project 7)goto [project menu]->[add reference]->[browse tab] 8)find and select ur OSWINSCK.DLL to add 9)swap ur codes with following : Dim LoginPacket As String Dim wsTCP As New OSWINSCK.Winsock LoginPacket = "GET http://login.yahoo.com/config?&login=" & "yourEmail@yahoo.com" & "&passwd=" & "yorEmailPass" & " HTTP/1.0" & vbCrLf LoginPacket = LoginPacket & "Accept: */*" & vbCrLf LoginPacket = LoginPacket & "Accept: text/html" & vbCrLf & vbCrLf LoginPacket = LoginPacket wsTCP.Protocol = OSWINSCK.ProtocolConstants.sckTCPProtocol wsTCP.SendData(LoginPacket) ============ if u have question: csharpisatechnology@yahoo.com http://mohammadhashemy.blogfa.com Im student of Iran.
    • Proposed as answer by crAckAlAckInz Saturday, June 16, 2012 3:40 AM
    • Unproposed as answer by crAckAlAckInz Saturday, June 16, 2012 3:40 AM
    Saturday, October 15, 2011 9:43 PM
  • ... the script given is correct except for one word,

    part 4:

    theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")

    this element is a button, not an input...

    theElementCollection = WebBrowser1.Document.GetElementsByTagName("Button")

    that should fix it

    Ive used a similar script for almost 3 years, still works

    answer = resolved     //  the.tutorial.geeks

    Saturday, June 16, 2012 3:45 AM
  • Thank you so much this post is helped to my project
    Wednesday, January 23, 2019 1:56 PM