• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Web Crawl - change web browser

Dave Wondrack

New Member
I attached an Excel sheet I have to browse key words on websites but it is written to use Internet Explorer as the web browser. Is it possible to change it so it uses whatever the default browser is? If not and you must specify a browser does anyone know how to change it from IE to Chrome?

Thank you in advance for taking the time to read my request.

Dave
__________________________________________________________________
Mod edit : post moved to appropriate forum …
 

Attachments


Native VBA can only pilot IE.

See an alternative way with selenium-vba tool
or use request as webbrowsers do …
 
I'd recommend sending request as Marc suggested. No need to open browser.

Something like below (using Google search) and then you need to search for text string or by element ID and tag name in HTML code.

Code:
Sub searchWordGoogle()

    Dim url As String, lastRow As Long
    Dim XMLHTTP As Object, html As Object, objResultDiv As Object, objH3 As Object, link As Object
    Dim start_time As Date
    Dim end_time As Date

    lastRow = Range("A" & Rows.Count).End(xlUp).Row
   
    Dim cookie As String
    Dim result_cookie As String
   
    start_time = Time
    Debug.Print "start_time:" & start_time

    For i = 2 To lastRow

        url = "https://www.google.com/search?q=" & Cells(i, 2) & "+site:" & Cells(i, 1)
        Set XMLHTTP = CreateObject("MSXML2.serverXMLHTTP")
        XMLHTTP.Open "GET", url, False
        XMLHTTP.setRequestHeader "Content-Type", "text/xml"
        XMLHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0"
        XMLHTTP.send

            Set html = CreateObject("htmlfile")
        html.body.innerHTML = XMLHTTP.ResponseText
        'Your text operation/search operation goes here
    Next
End Sub
 
Back
Top