+ Reply to Thread
Results 1 to 6 of 6

how to download webpage by skipping javascript

Hybrid View

  1. #1
    Registered User
    Join Date
    12-10-2010
    Location
    Hong Kong
    MS-Off Ver
    Excel 97
    Posts
    13

    Unhappy how to download webpage by skipping javascript

    I want to download the result of HKJC horse racing into Excel.
    http://www.hkjc.com/chinese/racing/results.asp
    or
    http://www.hkjc.com/chinese/racing/r...eno=8&venue=HV

    The actual size Saved by IE or other programming language should be round 40k.

    But there is a javascript to rewrite the result.
    Whatever I use,

    ActiveSheet.QueryTables.Add(Connection:="URL;" & sURL ...)
    URLDownloadToFile Lib "urlmon"
    InternetReadFile Lib "wininet.dll"
    nor
    CreateObject("MSXML2.ServerXMLHTTP") => to get objHttp.ResponseText
    all feedback me only around 10k and cut off the result part of the webpage.
    which is the executed result of javascript on the above given page!!!
    That javascript use document.write to rewrite the webpage and hide the RESULT from the original webpage.

    I need the result, by download the webpage and CUT-off all javascript from it.
    i.e. save the webpage from starting of "<body bgcolor"
    Then, the horse racing data will appear properly on excel by ActiveSheet.QueryTables.

    I don't want to save the webpage manually and cut-off the javascript by IE.
    What can I do?
    Last edited by catjoke; 12-30-2010 at 12:52 AM. Reason: Solved by myself.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: how to download webpage by skipping javascript

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: how to download webpage by skipping javascript

    Also, don't use bad language in your titles or posts

  4. #4
    Registered User
    Join Date
    12-10-2010
    Location
    Hong Kong
    MS-Off Ver
    Excel 97
    Posts
    13

    Re: how to download webpage by skipping javascript

    Function WebHTML(ByVal sURL As String) As String
        Dim objLink As HTMLLinkElement
        Dim objMSHTML As New MSHTML.HTMLDocument
        Dim objDocument As MSHTML.HTMLDocument
        
        Set objDocument = objMSHTML.createDocumentFromUrl(sURL, vbNullString)
       
        Do While objDocument.readyState <> "complete"
            DoEvents
            'Wscript.sleep 50
        Loop
        WebHTML = objDocument.documentElement.innerHTML
        Set objLink = Nothing
        Set objMSHTML = Nothing
        Set objDocument = Nothing
    End Function
    Tool->add reference-> Microsoft HTML object library
    This works now but ask security prompt x2 when run.

    can I skip the prompt?

    Another way is to CreateObject InternetExplorer.Application but IE crash easily after run few times.

  5. #5
    Registered User
    Join Date
    12-10-2010
    Location
    Hong Kong
    MS-Off Ver
    Excel 97
    Posts
    13

    Re: how to download webpage by skipping javascript

    Oh No.
    #4 return 99k when is also hide the result of horse racing.

    objMSHTML.designMode = "on"
    if I put above line, the security prompt is skipped but give back 11k similar to #1 result.

  6. #6
    Registered User
    Join Date
    12-10-2010
    Location
    Hong Kong
    MS-Off Ver
    Excel 97
    Posts
    13

    Re: how to download webpage by skipping javascript

    Finally, I upgrade VFP5 to VFP9 with SAME API InternetReadFile call to grap the innerHTML.

    I've tried open IE object to get innerHTML but IE crash after few runs.
    Thus, using VFP9 to get is the fastest way to do.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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