Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Capturing Return HTML
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00161948
Message ID:
00162154
Views:
23
Just take out the INTERNET_FLAG_RELOAD and change that to 0 and
content will come from Cache after the first hit. THere's another
flag you can use, too - INTERNET_FLAG_OFFLINE which *requires*
that output comes from cache...

+++ Rick ---



>I've borrowed the readurl function from David Frankenbach's web site, which he says he borrowed from TechNet and it works fairly well - usually. Apparently, it does a re-query on the url that gets passed and that html is stored in a variable.
>
>What I really need is a way to get to the html without hitting the server again, because some of the secure stuff on the internet will send back a page indicating there is a problem. It's not really a big deal because I can use Rick Strahl's wwipstuff to get this, I just thought if anyone knew of an api call or other way to get this it would be simpler.
>
>Here's the readurl function:
>
>
>PROCEDURE readurl
>* Purloined from David Frankenbach's web page 11/20/98.
>
>* readurl.prg 06-Mar-98* 06-Mar-98 pulled from Q174524 on March 98 Technet CD
>* 06-Mar-98 bug fixed about the length of the sReadBuffer
>*Note that Microsoft Internet Explorer must be installed on the computer.
>* passed: URLName, in the form "http://www.microsoft.com"*
>* returns: the content of the URL** usage:*
>*  uWebContent = ReadURL( "http://www.microsoft.com" )
>*  uWebContent = ReadURL( "http://www.SomeSite.com/SomeJPG.jpg" )** notes:
>* 1 - IE does not need to be running to use this, but must be installed,
>* as the program uses an option that gets information from the registry
>LPARAMETERS pcUrlName
>
>DECLARE INTEGER InternetOpen IN wininet.DLL STRING sAgent, ;
>	INTEGER lAccessType, STRING sProxyName, ;
>	STRING sProxyBypass, INTEGER lFlags
>
>DECLARE INTEGER InternetOpenUrl IN wininet.DLL ;
>	INTEGER hInternetSession, STRING sUrl, STRING sHeaders,;
>	INTEGER lHeadersLength, INTEGER lFlags, INTEGER lContext
>
>DECLARE INTEGER InternetReadFile IN wininet.DLL INTEGER hfile, ;
>	STRING @sBuffer, INTEGER lNumberofBytesToRead, INTEGER @lBytesRead
>
>DECLARE short InternetCloseHandle IN wininet.DLL INTEGER hInst
>
>#DEFINE INTERNET_OPEN_TYPE_PRECONFIG 0
>#DEFINE INTERNET_OPEN_TYPE_DIRECT 1
>#DEFINE INTERNET_OPEN_TYPE_PROXY 3
>#DEFINE SYNCHRONOUS 0
>#DEFINE INTERNET_FLAG_RELOAD 2147483648
>#DEFINE CR CHR(13)
>LOCAL lsAgent, lhInternetSession, lhUrlFile, llOk, lnOk, lcRetVal, lcReadBuffer, lnBytesRead
>* what application is using Internet services?
>lsAgent = "VPF 5.0"
>lhInternetSession = InternetOpen( lsAgent, INTERNET_OPEN_TYPE_PRECONFIG, ;
>	'', '', SYNCHRONOUS)
>* debugging line - uncomment to see session handle
>* WAIT WINDOW "Internet session handle: " + LTRIM(STR(hInternetSession))
>IF lhInternetSession = 0
>	WAIT WINDOW "Internet session cannot be established" TIME 2
>	RETURN .null.
>ENDIF
>lhUrlFile = InternetOpenUrl( lhInternetSession, pcUrlName, '', 0, ;
>	INTERNET_FLAG_RELOAD, 0)
>* debugging line - uncomment to see URL handle
>* WAIT WINDOW "URL Handle: " + LTRIM(STR(hUrlFile))
>IF lhUrlFile = 0
>	WAIT WINDOW "URL cannot be opened"
>	RETURN .null.
>ENDIF
>lcRetVal = ""
>llOk = .t.
>DO WHILE llOk
>* set aside a big buffer
>	lsReadBuffer = SPACE(32767)
>	lnBytesRead = 0
>	lnOk = InternetReadFile( lhUrlFile, @lsReadBuffer, LEN(lsReadBuffer), @lnBytesRead)
>	IF ( lnBytesRead > 0 )
>		lcRetVal = lcRetVal + left( lsReadBuffer, lnBytesRead )
>	ENDIF
>* error trap - either a read failure or read past eof()
>	llOk = ( lnOk = 1 ) and ( lnBytesRead > 0 )
>ENDDO
>* close all the handles we opened
>InternetCloseHandle( lhUrlFile )
>InternetCloseHandle( lhInternetSession )
>* return the URL contents
>RETURN lcRetVal
>
>
>
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform