Results 1 to 4 of 4

Web scraping

Threaded View

  1. #1
    Registered User
    Join Date
    08-30-2024
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    9

    Web scraping

    Hi - I am trying to understand how to interact with the web from VBA Macro. The code below will sometimes simulate inputting "atn x-sight 5" into Google Search and clicking the Google Search button. However, most of the time it does not work. If I step through the code and place the cursor after "atn x-sight 5" in the search box before executing the line "Element.click", it works every time. Please help.

    Sub Webscraping()
    Dim ie As InternetExplorer
    Dim ht As HTMLDocument
    
    Set ie = New InternetExplorer
    ie.Visible = True
    ie.navigate ("Googledotcom")                                     <=I can't actually type the URL here because I am not allowed according to my membership status
    
    Do Until ie.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop
    
    Set ht = ie.document
    
    ht.getElementsByName("q")().Value = "atn x-sight 5"
    
    Set elements = ht.getElementsByTagName("input")
    
    For Each element In elements
        If element.DefaultValue = "Google Search" Then
            element.Click
            Exit For
        End If
    Next
    End Sub
    Last edited by PhillipC; 09-16-2024 at 04:05 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Web Scraping using VBA
    By perpectuals in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2018, 03:08 PM
  2. help from web scraping
    By kirby21 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-31-2015, 08:59 PM
  3. Web Scraping with VBA
    By Branbran10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2015, 09:30 AM
  4. help web scraping vba
    By kirby21 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-24-2015, 09:34 PM
  5. Web scraping
    By vijay.jp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2015, 08:07 AM
  6. Web scraping
    By vijay.jp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-02-2015, 12:56 AM
  7. Web Scraping
    By Thomo88 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2014, 07:21 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1