RE: Internet UTC
- From: Linwood <lcox@xxxxxxxxxxxxxxx>
- Date: Tue, 12 Sep 2006 10:57:02 -0700
Hi Carlos
Here is a example of how to pull web pages from a fox application and sift
through the html for the data you want.
I was pulling stock quotes and pushing the results into sql server on a time
interval then sending alarm emails when thresholds were tripped but you can
use the same code to pull the time or any other data by changing the URL..
Good luck
Linwood
***********code*********************
Parameters pcSymbol
Local lcQuote As String, ;
lcTempTxtFile As String, ;
lnGetResults As Integer, ;
lcURL As String
lcQuote = ""
*-- Set up a variable referring to a temp .TXT file.
*-- Uses the current VFP TEMP DIR [SYS(2023)]
*-- and a random file name [SYS(2015)]
lcTempTxtFile = Forceext(Addbs(Sys(2023)) + Sys(2015), "TXT")
lnGetResults = 0
lcGetURl ="http://money.cnn.com/quote/quote.html?shownav=true&symb=" +
ALLT(pcSymbol)
Declare Long URLDownloadToFile In URLMON.Dll ;
LONG, String, String, Long, Long
*-- Get the quote using the Urlmon.dll and store it
*-- to a temp .TXT file.
*-- This function returns non-zero if it fails.
lnGetResults = URLDownloadToFile(0, lcGetURl, lcTempTxtFile, 0, 0)
If lnGetResults # 0
Messagebox("Download Failed",0,"")
Return .F.
Endif
*-- Read the Web page into a variable, and then erase it.
lcQuote = Filetostr(lcTempTxtFile)
Erase (lcTempTxtFile)
*-- Grab the quote from the Web page. If in VFP 7.0, we use the new
*-- STREXTRACT() function to grab the data between two delimiters.
*-- In VFP 6.0, use SUBSTR() to get the data, and then trim off any
*-- trailing HTML with the TRANSFORM() AND VAL() functions.
If Version(5) = 700
lcQuote = Strextract(lcQuote, [stockheader"> ], [<])
Else
*-- Extract the quote from the HTML
* lcQuote = Substr(lcQuote, Atc(["stockheader"], lcQuote) + 14, 8)
lcQuote=Substr(lcQuote, Atc([=40> ],lcQuote) + 10, 5)
*-- Trim off the trailing HTML. VAL() will only return the numbers,
*-- which we then change to a string with TRANSFORM()
lcQuote = Transform(Val(lcQuote))
Endif
Return lcQuote
"Carlos Jones" wrote:
Good day all,.
I am developing a personnel access control app and I do not want to rely
on system time to record the events, I rather prefer to read time from an
Internet server at application initialization. Users are able to change
datetime on their computers, this is a requirement some times to operate
another app so I can not block access to the system clock.
Does somebody know about an Internet Time Server, how to access it and
obtain the time? Some code sample woud be great !
Thank you in advance for your help.
Sincerely,
Carlos Jones.
- Follow-Ups:
- Re: Internet UTC
- From: Gene Wirchenko
- Re: Internet UTC
- References:
- Internet UTC
- From: Carlos Jones
- Internet UTC
- Prev by Date: Internet UTC
- Next by Date: Re: Internet UTC
- Previous by thread: Internet UTC
- Next by thread: Re: Internet UTC
- Index(es):
Relevant Pages
|