Consulting

Results 1 to 3 of 3

Thread: Grab data from Websites

  1. #1

    Grab data from Websites

    Hi All

    Is there a way to grab specific data from websites using VBA in MS Access. Will using SendKeys help?

  2. #2
    VBAX Regular
    Joined
    Jul 2010
    Posts
    66
    Location
    I found this code on the web somewhere a while ago, and use it on the few databases that I have that get webpages...

    [VBA]
    '***** Begin of Code *******
    '***
    '***
    '*** Call: a = Fetch("http://www.google.com","c:\google.html")
    '***
    '*** return TRUE on success
    '*** DOES NOT WORK

    Public Function Fetch(URL, dest)
    'On Error Resume Next
    Dim b
    Err.Clear
    With CreateObject("Microsoft.XMLHTTP")
    .Open "GET", URL, False
    .send
    b = .responseBody
    If Err.Number <> 0 Or .Status <> 200 Then
    Fetch = False
    Exit Function
    End If
    End With

    With CreateObject("ADODB.Stream")
    .Type = 1
    .Open
    .Write b
    .SaveToFile dest, 2
    End With

    Fetch = Err.Number = 0
    End Function
    '****** end of code *****
    [/VBA]

    That will fetch the entire webpage.. then you can parse it how you need to.

    GComyn

  3. #3
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Quote Originally Posted by Jeevie
    Hi All

    Is there a way to grab specific data from websites using VBA in MS Access. Will using SendKeys help?
    For 'specific' data, you probably have to be more specific. If it's table data Excel has built-in methods under the Data menu and you can transfer to Access.

    Assuming you are using IE, either an HTTP request, or direct web scraping using IE functions will get what you want. If you are attempting to fill table rows, for example, stock prices - web scraping is probably preferable, unless data can be obtained as XML or JSON in which case there are other tools to process those.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •