Retrieving a web page via shell.explorer

Postby James Bott » Wed Nov 26, 2008 12:13 am

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Wed Nov 26, 2008 12:17 am

Darrell,

Lets start with a first test. This should work fine:
Code: Select all  Expand view
#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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby cdmmaui » Wed Nov 26, 2008 12:45 am

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
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Postby Antonio Linares » Wed Nov 26, 2008 1:04 am

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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby cdmmaui » Wed Nov 26, 2008 1:31 am

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/maerskline/public?_nfpb=true&portlet_quickentries_2_actionOverride=%2Fportlets%2Fquickentries%2FtrackCargo&_windowLabel=portlet_quickentries_2&_pageLabel=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
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Postby Antonio Linares » Wed Nov 26, 2008 1:56 am

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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby cdmmaui » Wed Nov 26, 2008 2:27 am

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: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Postby cdmmaui » Wed Nov 26, 2008 2:47 am

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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Postby Horizon » Wed Nov 26, 2008 8:16 am

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 & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 52 guests