Retrieving a web page via shell.explorer

User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Darrell,

I believe Antonio says that you have to use the ON INIT clause like this:'

ACTIVATE WINDOW oWnd2 ON INIT oActiveX:Do( "Navigate2", cConnect,,, GetPostData( cGetPost ), "Content-Type: application/x-www-form-urlencoded" + CRLF )

Regards,
James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

Lets start with a first test. This should work fine:

Code: Select all

#include "FiveWin.ch" 

function Main() 

   local oWnd, oActiveX 
    
   DEFINE WINDOW oWnd 
    
   @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer" OF oWnd 
    
   oWnd:oClient = oActiveX 
    
   ACTIVATE WINDOW oWnd ; 
      ON INIT oActiveX:Do( "Navigate2",; 
                           "https://www.fivetechsoft.com/secure/english/test.php",,,; 
                           GetPostData( "first=fivewin&last=FiveTech Software" ),; 
                           "Content-Type: application/x-www-form-urlencoded" + CRLF ) 
    
return nil 

#pragma BEGINDUMP 

#include <hbapi.h> 
#include <windows.h> 

HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT * pVariant ); 

HB_FUNC( GETPOSTDATA ) 
{ 
   VARIANT vPostData = {0}; 
   LPSAFEARRAY psa; 
   LPCTSTR cszPostData = hb_parc( 1 ); 
   UINT cElems = lstrlen( cszPostData ); 
   LPSTR pPostData; 

   VariantInit( &vPostData ); 

   psa = SafeArrayCreateVector( VT_UI1, 0, cElems ); 
   if( ! psa ) 
   { 
      hb_retnl( E_OUTOFMEMORY ); 
      return; 
   } 

   SafeArrayAccessData( psa, ( LPVOID * ) &pPostData ); 
   memcpy( pPostData, cszPostData, cElems ); 
   SafeArrayUnaccessData( psa ); 

   V_VT( &vPostData ) = VT_ARRAY | VT_UI1; 
   V_ARRAY( &vPostData ) = psa; 

   hb_oleVariantToItem( hb_param( -1, HB_IT_ANY ), &vPostData ); 
} 

#pragma ENDDUMP      
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Antonio,

This produces the following output, is it correct?

This is a HTTPS post test. Please check your supplied data:

First: fivewin
Last: FiveTech Software
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

Yes, it is correct. Please notice that those values are the ones supplied here:

GetPostData( "first=fivewin&last=FiveTech Software" )

also, that we are using a HTTPS (secure) website.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Hi Antonio,

I tried the following code with no success.
//----------------------------------------------------------------------------------

#include "FiveWin.ch"

function Main()

local oWnd, oActiveX, cGetPost := ''

cGetPost := '_nfpb=true&_nfls=false&_pageLabel=page_tracking3_trackSimple'
cGetPost += '&portlet_trackSimple_1wlw-select_key:{pageFlow.trackSimpleForm.type}OldValue=true'
cGetPost += '&portlet_trackSimple_1wlw-select_key:{pageFlow.trackSimpleForm.type}=CONTAINERNUMBER'
cGetPost += '&portlet_trackSimple_1{pageFlow.trackSimpleForm.numbers}=CLHU2068151'


DEFINE WINDOW oWnd

@ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer" OF oWnd

oWnd:oClient = oActiveX

ACTIVATE WINDOW oWnd ;
ON INIT oActiveX:Do( "Navigate2",;
"http://www.maerskline.com:80/appmanager ... Label=home",,,;
GetPostData( cGetPost ),;
"Content-Type: application/x-www-form-urlencoded" + CRLF )

return nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT * pVariant );

HB_FUNC( GETPOSTDATA )
{
VARIANT vPostData = {0};
LPSAFEARRAY psa;
LPCTSTR cszPostData = hb_parc( 1 );
UINT cElems = lstrlen( cszPostData );
LPSTR pPostData;

VariantInit( &vPostData );

psa = SafeArrayCreateVector( VT_UI1, 0, cElems );
if( ! psa )
{
hb_retnl( E_OUTOFMEMORY );
return;
}

SafeArrayAccessData( psa, ( LPVOID * ) &pPostData );
memcpy( pPostData, cszPostData, cElems );
SafeArrayUnaccessData( psa );

V_VT( &vPostData ) = VT_ARRAY | VT_UI1;
V_ARRAY( &vPostData ) = psa;

hb_oleVariantToItem( hb_param( -1, HB_IT_ANY ), &vPostData );
}

#pragma ENDDUMP
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

Don't they provide a HTTPS url ?

I am going to bed now, we continue tomorrow :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Antonio,

They do not. I need to connect to about 50 or 60 websites and submit certain values and wait for the website to provide the information. Certain websites allow me to pass a string, for example www.search.com?container=POLU1234567 and the website will display the details. However, many other websites do not allow this and I am performing a work around by copying container number to clipboard then opening website, then instructing user to PASTE container number in appropriate field then clicking submit button.

I hope a solution is possible.
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Antonio,

I am able to get the data to post and get results on other websites. Perhaps the Maersk website I gave is blocking this function???
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Post by Horizon »

Darrell,

I think the problem is web site related. Both TIP class and ActiveX classes can post variables to web sites. Both examples are given before.
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
Post Reply