+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14

Thread: Retrieving Web Data using Excel

  1. #11
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by mehere View Post
    yes it's VBA? or yes it's what? ...
    yes, it's VBA
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  2. #12
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I have kind of a working example. Basically I just pulled the webpage into Excel and then dealt with the information from there.

    This is what I came up with. You'll have to be the judge of whether it's of any use to you!!!
    Code:
    Sub webpage()
        Dim cur_row As Integer
        Dim cur_col As Integer
        cur_col = 1
        cur_row = 0
        'opens the webpage
        Workbooks.Open Filename:= _
            "http://www.calculateme.com/car-insur...ey/absecon.htm"
            Rows("1:10").Delete 'delete the first 10 rows as they don't contain any data we want
            ActiveWorkbook.Worksheets.Add 'add our data sheet. Sheet is added at the front of the workbook, making it sheet(1) and the webpage sheet(2)
            For Each rw In ActiveWorkbook.Worksheets(2).Rows ' search in each row of the webpage sheet
            If Not IsEmpty(ActiveWorkbook.Worksheets(2).Cells(rw.Row, 1)) Then ' filter out any empty cells
            If (ActiveWorkbook.Worksheets(2).Cells(rw.Row, 1).Font.Bold = True) Then 'check if the text is bold (ie a heading)
            
            cur_col = 1 ' reset the column to 1
            cur_row = cur_row + 1 ' add 1 to the row
            ActiveWorkbook.Worksheets(1).Cells(cur_row, cur_col).Value = ActiveWorkbook.Worksheets(2).Cells(rw.Row, 1).Value ' set the value of the first column to the name from the webpage sheet
            ActiveWorkbook.Worksheets(1).Cells(cur_row, cur_col + 4).Value = ActiveWorkbook.Worksheets(2).Cells(rw.Row - 2, 1).Value ' get the distance value 2 lines above and put it at the end
            
            Else ' text is not bold
            
            If InStr(ActiveWorkbook.Worksheets(2).Cells(rw.Row, 1).Value, "distant") = 0 Then ' filter out the distance cells as we're writing these above
            cur_col = cur_col + 1 ' add 1 to the current column
            If cur_row = 0 Then cur_row = 1 ' originally set row to 0 if we were able to remove all rows that didn't contain data
            ActiveWorkbook.Worksheets(1).Cells(cur_row, cur_col).Value = ActiveWorkbook.Worksheets(2).Cells(rw.Row, 1).Value ' set the value of the current cell (cur_row,cur_col) to the value from the webpage row we're reading
            End If ' end of distance filter
            End If ' end of bold filter
            End If ' end of empty filter
            
            Next ' move to next row of webpage
            
    End Sub
    
    Obviously, that's just an example to deal with that specific type of page, but I guess you could adapt it to deal with different scenarios. The main point is to find something unique about the header of each block of data and deal with each row accordingly.

    Hope that helps.

  3. #13
    Barn Newbie dkopp is an unknown quantity at this point dkopp's Avatar
    Join Date
    May 2008
    Posts
    1
    Rep Power
    4

    more web data extraction

    I have an excel sheet with about 2000 rows. Each row links to a particular data I want to extract. The format on the website is always the same. Is there a way to extract the data into excel along the same row?

    Here is a link to a typical page:

    https://www.icsc.org/apps/dmmdisp.php?dispid=GA8837
    Last edited by dkopp; May 22nd, 2008 at 03:57 PM.

  4. #14
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by dkopp View Post
    I have an excel sheet with about 2000 rows. Each row links to a particular data I want to extract. The format on the website is always the same. Is there a way to extract the data into excel along the same row?

    Here is a link to a typical page:

    https://www.icsc.org/apps/dmmdisp.php?dispid=GA8837
    Welcome to DeveloperBarn

    Could you elaborate more on what you mean by "along the same row"? What exactly are you trying to achieve?
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

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

SEO by vBSEO