Results 1 to 3 of 3

Thread: Excel VBA Website login data extract

  1. #1

    Thread Starter
    Junior Member Fimpass's Avatar
    Join Date
    Feb 2017
    Location
    Romania
    Posts
    17

    Cool Excel VBA Website login data extract

    Hi guys,

    I got a little issue with the code below. What it dose is, extracts the data from a specific site that requires you to login. Basically you put the credentials into the source code then it will automatically go to the site, it will log you in and will go the the specific page that you want to copy. After that, the code copies the source code of the page and paste it into A1 cell of the specific sheet. How can I make the code paste the text of the site and not the source code. Thanks in advance.

    Code:
    Sub Button1_Click()
    
    
    Dim ieApp As InternetExplorer
    Dim ieDoc As Object
    Dim ieTable As Object
    Dim clip As DataObject
    
    'create a new instance of ie
    Set ieApp = New InternetExplorer
    
    'you don’t need this, but it’s good for debugging
    ieApp.Visible = True
    
    'assume we’re not logged in and just go directly to the login page
    ieApp.Navigate "http://fidghjdghkst.ro/login.php"
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    Set ieDoc = ieApp.Document
    
    'fill in the login form – View Source from your browser to get the control names
    With ieDoc.forms(0)
    .UserName.Value = "Usernamesfsdbgs"
    .Password.Value = "Passdigbisbdg"
    .submit
    End With
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    'now that we’re in, go to the page we want
    ieApp.Navigate "http://fidfhfghdt.ro/browse.php"
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    'get the table based on the table’s id
    Set ieDoc = ieApp.Document
    Set ieTable = ieDoc.all.Item("wrapper")
    
    'copy the tables html to the clipboard and paste to teh sheet
    If Not ieTable Is Nothing Then
    Set clip = New DataObject
    clip.SetText "" & ieTable.outerHTML & ""
    clip.PutInClipboard
    Sheet1.Select
    Sheet1.Range("A1").Select
    Sheet1.Paste
    
    End If
    
    'close 'er up
    ieApp.Quit
    Set ieApp = Nothing
    
    End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel VBA Website login data extract

    you can try either of
    clip.SetText "" & ieTable.outertext & ""
    clip.SetText "" & ieTable.innertext & ""
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member Fimpass's Avatar
    Join Date
    Feb 2017
    Location
    Romania
    Posts
    17

    Re: Excel VBA Website login data extract

    Thanks West !

Tags for this Thread

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