Consulting

Results 1 to 3 of 3

Thread: Get javascripts from a URL with VBA

  1. #1

    Get javascripts from a URL with VBA

    I am trying to use VBA to scrape some websites for information automatically.
    I use an internetExplorer object, and has until now been able to get what I need through the

    document.body.innerHtml

    method.

    Now however, the things I need are contained in a script in the header part of the page, more precisely, the page is page: hapag-lloyd.com//en/products_and_services/services_between_africa_and_asia.html
    And I need the arrays in the header with ports etc.

    Does anyone know how to acces that part of the file easily?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    You can parse the source text I guess. Here is one method to get the source text.

    [VBA]Sub Test_SourceTextToFileLB()
    SourceTextToFileLB "http://www.hapag-lloyd.com/en/products_and_services/services_between_africa_and_asia.html", _
    "C:\temp\services_between_africa_and_asia.txt"
    Shell "Notepad C:\temp\services_between_africa_and_asia.txt", vbNormalFocus
    End Sub

    Function SourceTextToFileLB(url As String, toFile As String)
    Dim Request As Object
    Dim ff As Integer
    Set Request = CreateObject("WinHttp.WinHttpRequest.5.1")

    Request.Open "GET", url, False
    Request.Send

    ff = FreeFile
    Open toFile For Output As #ff
    Print #ff, Request.ResponseText
    Close #ff

    SourceTextToFileLB = Request.StatusText
    End Function

    [/VBA]

  3. #3
    it works like a charm
    Nice with a quick and good response,

    Thanks a lot Kenneth,

Posting Permissions

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