Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming,microsoft.public.excel
|
|||
|
|||
![]()
Auric__ wrote:
Robert Baer wrote: Excel macros are SO... undocumented. Sure they are. Plenty of documentation for individual keywords. You're not looking for that, you're looking for a broader concept than individual keywords. Need a WORKING example for reading the HTML source a URL (say http://www.oil4lessllc.org/gTX.htm) Downloading a web page (or any URI, really) is easy: Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" (ByVal pCaller As Long, _ ByVal szURL As String, ByVal szFileName As String, _ ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long Sub foo() Dim tmp, result, contents tmp = Environ("TEMP")& Format$(Now, "yyyymmdd-hhmmss-")& "gTX.htm" 'download result = URLDownloadToFile(0, "http://www.oil4lessllc.org/gTX.htm", _ tmp, 0, 0) If result< 0 Then 'failed to download; error handler here Else 'read from file Open tmp For Binary As 1 contents = Space$(LOF(1)) Get #1, 1, contents Close 1 'parse file here '[...] 'cleanup End If Kill tmp End Sub (Note that URLDownloadToFile must be declared PtrSafe on 64-bit versions of Excel.) Dealing with the data downloaded is very dependant on what the page contains and what you want to extract from it. That page you mentioned contains 2 images and 2 Javascript arrays; assuming you want the data from the arrays, you could search for "awls[" or "aprd[" and get your data that way. Rather than downloading to a file, it is possible to download straight to memory, but I find it's simpler to use a temp file. Among other things, downloading to memory requires opening and closing the connection yourself; URLDownloadToFile handles that for you. Thanks. I know that the parsing is very dependent on the contents and what one wants. That is why i gave an example having at least one data array; similar to what i may be parsing. I too, like temp files because i can open them in random and/or binary mode if need. A bit of fun to read such backwards (like BMP files). Thanks again. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
EOF Parse Text file | Excel Programming | |||
Parse a txt file and save as csv? | Excel Programming | |||
parse from txt file | Excel Programming | |||
Parse File Location | Excel Worksheet Functions | |||
REQ: Simplest way to parse (read) HTML formatted data in via Excel VBA (or VB6) | Excel Programming |