Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can VFP 'control' netscape or IE?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00045050
Message ID:
00045069
Views:
31
>I'd like to write a VFP program that controls a browser to:
>
>1) Open a specific web page using a URL from 'the database'
>2) Read the source to extract all the links and add all the (unique) URLs to the database
>3) Go to the next URL in the database and start over at step (1).
>
>Any ideas?
>
>Thanks in advance

you can use the microsoft web browser control in your app. if you have internet explorer installed, you should be able select it as an active x control ( i think it's listed as "Microsoft Web Broswer Control" ) to embed a browser in your form.
i'm sure one of the methods of the control will let you read the html source and parsing files isn't too bad in fox.
you can use the control to navigate url's also.

if you want your form to launch the browser with a specific url, i grabbed the following code out of foxpro advisor some time ago and it works quite well.

****************
*. GO_URL.prg
*. Opens the passed in url in the default browser
*. if the browser is already open, it will use that
*. instance otherwise it will start an instance
*> chrUrl - the url to go to
*< intRetVal - value indicating success
*. 1 - non character or no url passed in
*. 2 - invalid url
*. 29 - failure to load application
*. 30 - application is busy
*. 31 - no application association
*. > 32 success and the value is an instance handle to the browser
********************
PARAMETERS chrUrl
PRIVATE chrUrl, intRetVal

*. declare the dlls we need
DECLARE INTEGER ShellExecute ;
IN SHELL32.dll ;
INTEGER nWinHandle, ;
STRING cOperation, ;
STRING cFileName, ;
STRING cParameters, ;
STRING cDirectory, ;
INTEGER nShowWindow
DECLARE INTEGER FindWindow ;
IN WIN32API ;
STRING cNull, ;
STRING cWinName

IF TYPE( "chrUrl" ) = "C"
intRetVal = ShellExecute( FindWindow( 0, _SCREEN.caption), ;
"Open", ;
@chrUrl, ;
"", ;
"c:\temp\", ;
0 )
ELSE
intRetVal = 1
ENDIF

IF intRetVal < 32
=messagebox( "Unable to open URL!", 16, _chrProgram )
ENDIF

RETURN( intRetVal )
Previous
Reply
Map
View

Click here to load this message in the networking platform