Results 1 to 12 of 12

Thread: [2008] Login to a web page

  1. #1

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    [2008] Login to a web page

    Hi!!

    I want to login to a web page, without using the Webbrowser control. Just connect to the website input the data in the correct fields and hit a button, but all behind the scenes. Is this possible?

    Thks
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2008] Login to a web page

    How about plain HTMLDocument? You can instantiate one using CreateDocumentFromURL.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] Login to a web page

    Hello there,

    If I am not mistaken, you should be able to do this using the WebClient Component:

    http://msdn.microsoft.com/en-us/libr...nt(VS.80).aspx

    Hope this helps!!

    Gary

  4. #4

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Re: [2008] Login to a web page

    Quote Originally Posted by dee-u
    How about plain HTMLDocument? You can instantiate one using CreateDocumentFromURL.
    Can find that method? Can you give a small example?
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2008] Login to a web page

    You'll have to use WebRequest or HttpWebRequest to send all the data. You'll first need to examine the page and look at the values that the target page is expecting. For example, it could be a username, a password and a few other tokens.

    However just logging in to a website in and of itself makes no sense. What is the end-goal here?

  6. #6

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Re: [2008] Login to a web page

    Quote Originally Posted by gep13
    Hello there,

    If I am not mistaken, you should be able to do this using the WebClient Component:

    http://msdn.microsoft.com/en-us/libr...nt(VS.80).aspx

    Hope this helps!!

    Gary
    Thks I was able to get the source code of the webpage using the webclient, but how can I input text into the textboxes or hit the buttons on the page?
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  7. #7

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Re: [2008] Login to a web page

    Quote Originally Posted by mendhak
    However just logging in to a website in and of itself makes no sense. What is the end-goal here?
    The idea is to create a windows application of a website. First I need to login to the site. Then get the data from the source code to show up on the form, as well send data from the form to the site. But never show the actual site to the end user.
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  8. #8
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2008] Login to a web page

    Here is how we can use CreateDocumentFromURL, it is pretty much the same as using a WebBrowser without a GUI interface.
    VB Code:
    1. Imports System.Diagnostics
    2. Imports System
    3. Imports System.Runtime
    4. Imports System.Runtime.InteropServices
    5. Imports System.Runtime.InteropServices.ComTypes
    6.  
    7. Public Class Form2
    8.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    9.         Dim doc1 As New mshtml.HTMLDocument
    10.         Dim doc2 As mshtml.HTMLDocument
    11.         doc2 = GetDocument("http://www.vbforums.com")
    12.         MessageBox.Show(doc2.documentElement.innerHTML)
    13.     End Sub
    14.  
    15.     Private Function GetDocument(ByVal url As String) As mshtml.HTMLDocument
    16.         Dim htmldoc As mshtml.HTMLDocumentClass
    17.         Dim htmldoc2 As mshtml.HTMLDocument
    18.  
    19.         htmldoc = New mshtml.HTMLDocumentClass()
    20.         Dim ips As IPersistStreamInit = DirectCast(htmldoc, IPersistStreamInit)
    21.  
    22.         ips.InitNew()
    23.         htmldoc2 = htmldoc.createDocumentFromUrl(url, Nothing)
    24.         While htmldoc2.readyState <> "complete"
    25.             Application.DoEvents()
    26.         End While
    27.         Return htmldoc2
    28.     End Function
    29.  
    30. End Class

    IPersistInterface for Access Violation exception
    VB Code:
    1. Imports System
    2. Imports System.Runtime
    3. Imports System.Runtime.InteropServices
    4. Imports System.Runtime.InteropServices.ComTypes
    5.  
    6. Public Enum HRESULT
    7.     S_OK = 0
    8.     S_FALSE = 1
    9.     E_NOTIMPL = &H80004001
    10.     E_INVALIDARG = &H80070057
    11.     E_NOINTERFACE = &H80004002
    12.     E_FAIL = &H80004005
    13.     E_UNEXPECTED = &H8000FFFF
    14. End Enum
    15.  
    16. 'IPersistStreamInit interface
    17. <ComVisible(True), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
    18. InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
    19. Public Interface IPersistStreamInit : Inherits IPersist
    20.  
    21.     Shadows Sub GetClassID(ByRef pClassID As Guid)
    22.     <PreserveSig()> Function IsDirty() As Integer
    23.     <PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As HRESULT
    24.     <PreserveSig()> Function Save(ByVal pstm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) As HRESULT
    25.     <PreserveSig()> Function GetSizeMax(<InAttribute(), Out(), _
    26.     MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As HRESULT
    27.     <PreserveSig()> Function InitNew() As HRESULT
    28.  
    29. End Interface
    30.  
    31. ' IPersist interface
    32. <ComVisible(True), ComImport(), Guid("0000010c-0000-0000-C000-000000000046"), _
    33. InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
    34. Public Interface IPersist
    35.     Sub GetClassID(ByRef pClassID As Guid)
    36.  
    37. End Interface
    Last edited by dee-u; Feb 2nd, 2009 at 04:00 PM.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  9. #9

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Re: [2008] Login to a web page

    For some reason unknown to me I'm getting an error on this line:
    vb Code:
    1. Dim doc1 As New mshtml.HTMLDocument
    saying that "Type 'mshtml.HTMLDocumentClass' is not defined". Shouldn't this class come with Framework?
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  10. #10
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2008] Login to a web page

    Yes it should. Have you added the reference for Microsoft.mshtml?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Re: [2008] Login to a web page

    Damm, cant find it, is it a COM?
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  12. #12
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2008] Login to a web page

    No, its .Net.
    Attached Images Attached Images  
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width