+ Reply to Thread
Results 1 to 4 of 4

Scraping a specific <td> tag that is nested inside a <tr> tag with VBA

  1. #1
    Forum Contributor
    Join Date
    01-06-2011
    Location
    cleveland
    MS-Off Ver
    Excel 2007
    Posts
    225

    Scraping a specific <td> tag that is nested inside a <tr> tag with VBA

    the html i am trying to scrape:

    HTML Code: 
    I am trying to scrape data from a website that has html structured like this within VBA. the value of interest that I want is "750" however it can sometimes be 0, 1,000,000, or any number in between so a set number of characters to extract wont work.

    can anyone give some insight on the best way to scrape this? this is my code that will import all of the text as is, but the logic to post process and trim the data of interest is proving very difficult so i am looking for a nice clean way to scrape the 750 slot (the second <td> tag that is nested in this <tr>) as is.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Scraping a specific <td> tag that is nested inside a <tr> tag with VBA

    One solution is to clean the <> sets
    1. find a "td><td>"
    2. delete up to the ">"
    locate the next "<"
    3. the seeked number is in between


    <tr><td>Tanks:<br /><i>Lost:<br />Destroyed:</i></td><td>750<br /><i>6<br />18</i></td></tr>

  3. #3
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Scraping a specific <td> tag that is nested inside a <tr> tag with VBA

    If the number always starts at character 58, then this will tell you the number of digits:
    Please Login or Register  to view this content.
    and then this will give you the number you want:
    Please Login or Register  to view this content.
    If the number can start elsewhere, the following can extract the number:
    Please Login or Register  to view this content.
    Last edited by mgs73; 01-05-2015 at 08:33 PM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Scraping a specific <td> tag that is nested inside a <tr> tag with VBA

    Try
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 'And' nested inside 'sumif'
    By ekirwa2 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-28-2013, 02:24 PM
  2. [SOLVED] RIGHT Function nested inside of IF
    By jakeisbill in forum Excel General
    Replies: 6
    Last Post: 10-16-2012, 12:01 PM
  3. Can i add an IF inside of an IF? (nested?)
    By Bajungadustin in forum Excel General
    Replies: 3
    Last Post: 05-27-2011, 04:22 PM
  4. Nested AND or IF inside of count
    By wmatthai in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-26-2010, 03:48 PM
  5. A range inside a nested IF
    By Nitz in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 02-26-2009, 03:55 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