INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

API Functions

How to retreive HTML code from a web page by mgagnon
Posted: 13 Apr 03


PUBLIC oForm
oForm = CREATEOBJECT("form")
oForm.addobject("edit1","editbox")
oForm.edit1.visible=.t.
oform.height = 400
oform.width = 400
oform.edit1.width=390
oform.edit1.height=390
oForm.autocenter=.t.
oForm.edit1.controlsource = "mycursor.contents"

Create Cursor myCursor (contents m)
Append Blank
Replace contents With FETCHURL( "http://www.microsoft.com" ) && Change this as required
oForm.show()
Function FETCHURL
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
lsAgent = "VPF"

lhInternetSession = InternetOpen( lsAgent, INTERNET_OPEN_TYPE_PRECONFIG, ;
    '', '', SYNCHRONOUS)
If lhInternetSession = 0
    Wait Window "Internet session cannot be established" Time 2
    Return .Null.
Endif
lhUrlFile = InternetOpenUrl( lhInternetSession, pcUrlName, '', 0, ;
    INTERNET_FLAG_RELOAD, 0)
If lhUrlFile = 0
    Wait Window "URL cannot be opened"
    Return .Null.
Endif
lcRetVal = ""
llOk = .T.
Do While llOk
    lsReadBuffer = Space(32767)
    lnBytesRead = 0
    lnOk = InternetReadFile( lhUrlFile, @lsReadBuffer, Len(lsReadBuffer), @lnBytesRead)
    If ( lnBytesRead > 0 )
        lcRetVal = lcRetVal + Left( lsReadBuffer, lnBytesRead )
    Endif
    llOk = ( lnOk = 1 ) And ( lnBytesRead > 0 )
Enddo
InternetCloseHandle( lhUrlFile )
InternetCloseHandle( lhInternetSession )
Return lcRetVal
Endfunc


Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close