Results 1 to 4 of 4

Understand web query code

Threaded View

kazshaz Understand web query code 04-26-2015, 10:04 AM
JasperD Re: Understand this code 04-26-2015, 10:32 AM
AB33 Re: Understand this code 04-26-2015, 11:22 AM
JasperD Re: Understand this code 04-26-2015, 12:46 PM
  1. #1
    Registered User
    Join Date
    04-24-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    6

    Understand web query code

    Hey guys, I am trying to understand this code, I was wondering if some helps so I can add some annotations.
    I normally use create internet explorer but I was told to use this for api websites.

    Dim URL As String, lastRow As Long
    Dim XMLHTTP As Object, html As Object, objResultDiv As Object, objH3 As Object, link As Object
    
    Dim hylink As String
    
    
        lastRow = Range("A" & Rows.Count).End(xlUp).Row
    
        Dim cookie As String
        Dim result_cookie As String
    
    
        For i = 2 To lastRow
    
            URL = "https://www.google.co.in/search?q=" & Cells(i, 1) & "&rnd=" & WorksheetFunction.RandBetween(1, 10000)
    
            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
            Set objResultDiv = html.getelementbyid("rso")
            Set objH3 = objResultDiv.getElementsByTagName("H3")(0)
            Set link = objH3.getElementsByTagName("a")(0)
    
    
            str_text = Replace(link.innerHTML, "<EM>", "")
            str_text = Replace(str_text, "</EM>", "")
    
            Cells(i, 2) = str_text
            Cells(i, 3) = link.href
            DoEvents
            
        Next
    Last edited by zbor; 04-27-2015 at 05:13 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. can't understand code
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2015, 08:03 PM
  2. [SOLVED] Understand what the following code does
    By Stanley91 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-08-2014, 06:14 AM
  3. Trying to Understand VBA Code....
    By konquistador in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2009, 04:35 PM
  4. Understand code
    By smlaff01 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-15-2007, 04:04 PM
  5. Help me understand this code
    By Carrot in forum Excel General
    Replies: 2
    Last Post: 10-14-2005, 01:07 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