none
Web Scraping Challenge RRS feed

  • Question

  • Hello all.  I'm stuck on something that seems pretty easy, but something is off here.  Thus, my question.  I'm trying to login to a webpage and click an icon, which is an gif file.  This the the 'submit button', but it's not an actual button.  Here's what it looks like.

    I'm thinking that there should be a way to reach the 'cursor: pointer' because that seems to have a click event option.  Is that doable?  I've tried looping through the elements in the webpage, but I just can't seem to reach this object.  Here is my code.  How can I do this?

    Dim HTMLDoc As HTMLDocument
    Dim oBrowser As InternetExplorer
    Sub Login_2_Website()
    
    Dim oHTML_Element As IHTMLElement
    Dim sURL As String
    Dim links, link
    
    On Error GoTo Err_Clear
    sURL = "http://my_web_site"
    Set oBrowser = New InternetExplorer
    oBrowser.Silent = True
    oBrowser.timeout = 60
    oBrowser.navigate sURL
    oBrowser.Visible = True
    
    Do
    ' Wait till the Browser is loaded
    Loop Until oBrowser.readyState = READYSTATE_COMPLETE
    
    Set HTMLDoc = oBrowser.document
    
    HTMLDoc.all.signupEmail.Value = "myemail"
    HTMLDoc.all.signupPassword.Value = "mypassword"
    
    
    For Each img In HTMLDoc.images
        If InStr(img.src, "hom_fl.gif") Then
        img.Click
    Exit For
    End If
    Next
    
    
    ' oBrowser.Refresh ' Refresh If Needed
    Err_Clear:
    If Err <> 0 Then
    Debug.Assert Err = 0
    Err.Clear
    Resume Next
    End If
    End Sub

    Thanks!!




    MY BOOK



    • Edited by ryguy72 Wednesday, July 17, 2019 10:11 PM
    Wednesday, July 17, 2019 8:22 PM

All replies

  • I've given up on Microsoft Internet Controls.  They just don't work with most webpages.  I suggest you use SeleniumBasic.  It is dated.  It works with IE.  If you update Chrome webdriver it works with current version of Chrome.  There is a convoluted way to get Edge to work.  Forget Firefox.  I prefer to use XPath to select elements.

    Here are steps to update chromedriver.exe.  SeleniumBasic installs in C:\Users\ <user>\AppData\Local\SeleniumBasic.  Go to ChromeDriver - WebDriver for Chrome

    Download driver that matches your version of ChromeReplace driver

    Look at Excel examples.

    Wednesday, July 17, 2019 8:52 PM