View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming
Walter Briscoe Walter Briscoe is offline
external usenet poster
 
Posts: 279
Default Watchdog timer issues

In message of Sun, 30 Oct 2016 17:36:45 in
microsoft.public.excel.programming, GS writes
In message of Sat, 29 Oct 2016
17:52:09 in microsoft.public.excel.programming, GS
writes
Not sure why you're automating IE since most things it does can be
accessed directly via APIs with no wait time!


Gary, I know no better.
What APIs do you refer to?
I send a URL, await a response and analyse ie.doc.
I repeat, I know no better. ;)


Have a look at my replies to the post by Robert Baer in this forum on
May 26th to see if it applies to what you are trying to do...


Subject of his post is...

"Read (and parse) file on the web"


Thanks!
I had a look at your contributions to this 92 member thread.
I saw 2 interesting "names": URLDownloadToFile and fParseWebPages.frm.
I googled URLDownloadToFile.
I adapted a web example. (I later found an example from Auric in the
thread.)
When I opened the downloaded page in IE, it looked different - simpler.
I made another example, which downloaded to memory. The download was
about 120k, compared with 110k.
I converted that example to write to a file. The file was similarly
simpler.
I would like an API technique to convert the downloaded HTML to DOM.
I have a reliable - but slow - method for analysing DOM information.
While Googling, I learned Regular Expressions are not recommended for
HTML analysis.

I also grabbed ParseWebPages.zip from https://www.nsncenter.com/NSN/.
When I ran the code, I got "Method or data member not found" referring
to webbrowser in

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("PgNum") Then
Range("WebAddr") = gsUrl1 & Target.Value: Me.WebBrowser1.Navigate
Range("WebAddr"): SetBtnState
End If
End Sub

I found no "Me" definition.

My understanding is zilch, but I am happy to learn.

OOPS! I nearly forgot to quote my example code:

Public 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

Private Function GetWebPage(ByRef URL As String) As String
Dim xml As Object ' need reference to get IXMLHTTPRequest
On Error Resume Next
Set xml = CreateObject("Microsoft.XMLHTTP")
With xml
.Open "GET", URL, False
.send
GetWebPage = .responseText
End With
Set xml = Nothing ' Is this needed?
End Function

Public Function DownloadFile1() As String
Dim lngRetVal As Long
Dim hFile As Long
Dim localFilename As String
Dim strCurrentURL As String
Dim content As String

localFilename = "C:\Users\IBM\AppData\Roaming\Microsoft\Excel\Down lo
ad.htm"
strCurrentURL = "https://tfl.gov.uk/bus/stop/490000235Z/new-oxford-
street?"
If True Then
content = GetWebPage(strCurrentURL)
hFile = FreeFile
Open localFilename For Output As #hFile
Write #hFile, content
Close #hFile
Else
lngRetVal = URLDownloadToFile(0, strCurrentURL, localFilename, 0, 0)
End If
hFile = FreeFile
Open localFilename For Input As #hFile
DownloadFile1 = Input$(LOF(hFile), hFile)
Close #hFile
End Function

Public Function DownloadFile0() As String
Dim lngRetVal As Long
Dim hFile As Long
Dim localFilename As String
Dim strCurrentURL As String

localFilename = "C:\Users\IBM\AppData\Roaming\Microsoft\Excel\Down lo
ad.htm"
strCurrentURL = "https://tfl.gov.uk/bus/stop/490000235Z/new-oxford-
street?"
lngRetVal = URLDownloadToFile(0, strCurrentURL, localFilename, 0, 0)
hFile = FreeFile
Open localFilename For Input As #hFile
DownloadFile = Input$(LOF(hFile), hFile)
Close #hFile
End Function

--
Walter Briscoe