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
Printable View
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
How about plain HTMLDocument? You can instantiate one using CreateDocumentFromURL.
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
Can find that method? Can you give a small example?Quote:
Originally Posted by dee-u
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?
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?Quote:
Originally Posted by gep13
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.Quote:
Originally Posted by mendhak
Here is how we can use CreateDocumentFromURL, it is pretty much the same as using a WebBrowser without a GUI interface.
VB Code:
Imports System.Diagnostics Imports System Imports System.Runtime Imports System.Runtime.InteropServices Imports System.Runtime.InteropServices.ComTypes Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim doc1 As New mshtml.HTMLDocument Dim doc2 As mshtml.HTMLDocument doc2 = GetDocument("http://www.vbforums.com") MessageBox.Show(doc2.documentElement.innerHTML) End Sub Private Function GetDocument(ByVal url As String) As mshtml.HTMLDocument Dim htmldoc As mshtml.HTMLDocumentClass Dim htmldoc2 As mshtml.HTMLDocument htmldoc = New mshtml.HTMLDocumentClass() Dim ips As IPersistStreamInit = DirectCast(htmldoc, IPersistStreamInit) ips.InitNew() htmldoc2 = htmldoc.createDocumentFromUrl(url, Nothing) While htmldoc2.readyState <> "complete" Application.DoEvents() End While Return htmldoc2 End Function End Class
IPersistInterface for Access Violation exception
VB Code:
Imports System Imports System.Runtime Imports System.Runtime.InteropServices Imports System.Runtime.InteropServices.ComTypes Public Enum HRESULT S_OK = 0 S_FALSE = 1 E_NOTIMPL = &H80004001 E_INVALIDARG = &H80070057 E_NOINTERFACE = &H80004002 E_FAIL = &H80004005 E_UNEXPECTED = &H8000FFFF End Enum 'IPersistStreamInit interface <ComVisible(True), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _ InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _ Public Interface IPersistStreamInit : Inherits IPersist Shadows Sub GetClassID(ByRef pClassID As Guid) <PreserveSig()> Function IsDirty() As Integer <PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As HRESULT <PreserveSig()> Function Save(ByVal pstm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) As HRESULT <PreserveSig()> Function GetSizeMax(<InAttribute(), Out(), _ MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As HRESULT <PreserveSig()> Function InitNew() As HRESULT End Interface ' IPersist interface <ComVisible(True), ComImport(), Guid("0000010c-0000-0000-C000-000000000046"), _ InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _ Public Interface IPersist Sub GetClassID(ByRef pClassID As Guid) End Interface
For some reason unknown to me I'm getting an error on this line:
saying that "Type 'mshtml.HTMLDocumentClass' is not defined". Shouldn't this class come with Framework?vb Code:
Dim doc1 As New mshtml.HTMLDocument
Yes it should. Have you added the reference for Microsoft.mshtml?
Damm, cant find it, is it a COM?
No, its .Net.