VBA Web search

Noobllianz

New Member
Joined
Jul 1, 2018
Messages
18
Hi Everyone.

Appreciate if you can help me before I go insane.

I have some started some code where I am making a search Bing (I had trouble finding google headers)

  1. search bing using a string (I have code which splits it apart and I have some formulas to get the url)
  2. Find all h2 Headings
  3. innertext? I would love the h2 headings and the text below it.

I need to get all the h2 headers on the first page and the text below it.

I have tried in my code to paste it into a listbox but i keep getting "object HTML Heading Element".

Is there a way to print all results in columns and row by row?

Just need the first 10 results

I dont mind if the results are placed into cells.

Appreciate the help please.




Code:
Sub test()

Dim insured As String
Dim fullname As Variant
Dim i As Integer
Dim strAddress As String
Dim strAddressParts() As String
Dim numParts As Integer
Dim lastrow As Long
Dim ie As Object
Dim tabclass As Object
Dim li As Object




Sheets("Engine").Range("A1:A15").ClearContents
     strAddress = Sheets("Sheet1").Range("C4").Value


        strAddressParts = Split(strAddress, " ")
        numParts = UBound(strAddressParts) + 1


Sheets("Engine").Range("A1").Resize(numParts).Value = WorksheetFunction.Transpose(strAddressParts)




        insured = Sheets("Engine").Range("C1")


        Set ie = CreateObject("InternetExplorer.Application")
        my_url = insured
        ie.Visible = True
        ie.navigate my_url


   Do While ie.readyState = 4: DoEvents: Loop
        Do Until ie.readyState = 4: DoEvents: Loop
     
     Application.Wait (Now + TimeValue("0:00:02"))
          
     ''''''''''''''''''''''''''''''''''''''''''''''''
     
Set Allhyperlinks = ie.document.getElementsByTagName("h2")
       
      Sheet1.ListBox1.Clear
            
        For Each hyper_link In Allhyperlinks
                        
        Sheet1.ListBox1.AddItem (hyper_link)
 
Next
End Sub
 
Last edited:

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Watch MrExcel Video

Forum statistics

Threads
1,127,621
Messages
5,625,927
Members
416,143
Latest member
JoyceMB

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top