Simple Web Scrape

TNTScrub

New Member
Joined
Jan 7, 2021
Messages
14
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi guys, I've done a bit of interacting with IE but I have never even attempted to scrape so I'm a bit overwhelmed. For the sake of simplicity I've got a number in A1 then I run a macro that does some web magic and eventually takes me to a page based on that number. What I need to accomplish is to extract one result ( <td>16989<td> )from an HTML table and place it in B1. Can I do something like this???

VBA Code:
   Table = ie.Document.getelementbyid("GridView_CyclesFound")
   IndexKey = ie.Document.getelementbytagname("td")
   
   [B1] = IndexKey

HTML:
<table id="GridView_CyclesFound" style="width: 620px; color: rgb(51, 51, 51);" cellspacing="2" cellpadding="4">
    <tbody>
        <tr style="color: white; font-weight: bold; background-color: rgb(93, 123, 157);">
            <th scope="col">Index Key</th>
            <th scope="col">Tag#</th>
            <th scope="col">Current Tech</th>
            <th scope="col">Select New Tech</th>
        </tr>
        <tr style="color: rgb(51, 51, 51); background-color: rgb(247, 246, 243);">
            <td>16989</td>
            <td>9753</td>
            <td>E000000 - Unassigned</td>


Honestly I think this is probably beginner level easy but I just don't know enough about this to make it work. Please help.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try this:
VBA Code:
Dim Table As Object
Set Table = ie.Document.getElementById("GridView_CyclesFound")
Range("B1").Value = Table.Rows(1).Cells(0).innerText
 
Upvote 0
Solution
Try this:
VBA Code:
Dim Table As Object
Set Table = ie.Document.getElementById("GridView_CyclesFound")
Range("B1").Value = Table.Rows(1).Cells(0).innerText
John, That is perfect. I didn't know you could navigate through an HTML table that way. Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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
Back
Top