Retrieving a web page via shell.explorer

Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Post by Horizon »

Hi

This is the another working example of posting datas using TIP class.

Code: Select all


#include "FiveWin.ch"

PROCEDURE Main
LOCAL oDlg

DEFINE DIALOG oDlg

@ 2,1 BUTTON oBtn PROMPT "Post Data to FiveTech" ACTION POST()

ACTIVATE DIALOG oDlg CENTERED

RETURN


PROCEDURE POST()
LOCAL oHttp, cHtml, hQuery, aLink, oNode, oDoc

   oHttp:= TIpClientHttp():new( "http://www.fivetechsoft.com/secure/english/test.php" )
   
   hQUery := Hash()
   hSetCaseMatch( hQuery, .F. )

   hQuery["first"]  := "fivewin"
   hQuery["last"]   := "FiveTech Software"

   // Connect to the HTTP server
   IF .NOT. oHttp:open()
      ? "Connection error:", oHttp:lastErrorMessage()
      QUIT
   ENDIF
   oHttp:Post(hQuery)

   cHtml   := oHttp:readAll()
   oHttp:close()
   oDoc := THtmlDocument():new( cHtml )
   oDoc:writeFile( "download.html" )

   msgInfo("Look at the download.html in this directory.")

RETURN
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Hello,

I am trying to get this function to work with the following two websites. However, I cannot get data to post so web page displays information. I would appreaciate your help to resolve this problem.

Website #1:
Field Name = searchText
Field Value = NYKU7940156
http://www2.nykline.com/ct/containerSea ... ountry=USA

Website #2:
Field Name1 = portlet_trackSimple_1wlw-select_key:{pageFlow.trackSimpleForm.type}
Field Value1 = CONTAINERNUMBER

Field Name2 = portlet_trackSimple_1{pageFlow.trackSimpleForm.numbers}
Field Value2 = MAEU8279199

http://www.maerskline.com/appmanager/ma ... rackSimple
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Post by Horizon »

Hi Darrell,

First of all, I must say that I am also newby in FWH. The Guru's of FWH might answer your questions.

I think there are several reason for this:

1. "searchText" is wrong. 2. This web site is different than asp and php.

I have setup the test.asp in my web site like below.

Code: Select all

<html>
<body>
<%
search=request("searchText") 
lang = request("lang")
country = request("country")

response.write "searchText = "
response.write search+"<br>"
response.write "lang = "
response.write lang+"<br>"
response.write "country = "
response.write country+"<br>"
%>
</body>
</html>
and changed the my test.prg like below.

Code: Select all

#include "FiveWin.ch"

PROCEDURE Main
LOCAL oDlg

DEFINE DIALOG oDlg

@ 2,1 BUTTON oBtn PROMPT "Post data to Web Site" ACTION POST()

ACTIVATE DIALOG oDlg CENTERED

RETURN


PROCEDURE POST()
LOCAL oHttp, cHtml, hQuery, aLink, oNode, oDoc

   oHttp:= TIpClientHttp():new( "http://www.objekt.com.tr/fwh_test/test.asp?lang=en&country=USA" )
   
   hQUery := Hash()
   hSetCaseMatch( hQuery, .F. )

   hQuery["searchText "]  := "NYKU7940156"

   // Connect to the HTTP server
   IF .NOT. oHttp:open()
      ? "Connection error:", oHttp:lastErrorMessage()
      QUIT
   ENDIF
   oHttp:Post(hQuery)

   cHtml   := oHttp:readAll()
   oHttp:close()
   oDoc := THtmlDocument():new( cHtml )
   oDoc:writeFile( "download.html" )

   msgInfo("Look at the download.html in this directory.")

RETURN
This is screen of the download.html created:

Code: Select all

searchText = NYKU7940156
lang = en
country = USA
If post variable is wrong, You shuold find this from author of web site.
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Thank You Horizon,

I am getting two unresolved external references.

_HB_FUN_TIPCLIENTHTTP
_HB_FUN_THTMLDOCUMENT

What library needs to be linked?

Thank You Again,
*~*~*~*~*~*~*~*~*~*
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 »

Horizon,

Sorry, I found tip.lib and program linked ok.
*~*~*~*~*~*~*~*~*~*
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,

My current version of FWH is 8.07, do I need to upgrade to 8.10 in order to get this function to work.

Thank You,
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Post by Horizon »

Hi Darrell,

What is you exact problem?. Did you get an error ? or not compiled?. If you get an error, can you post it here?
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Hi Horizon,

I tried to pull webpage using your source and changed web address, however I did not get a response, only the same page.

//----------------------------------------------------------------------------------
#include "FiveWin.ch"

PROCEDURE Main
LOCAL oDlg

DEFINE DIALOG oDlg

@ 2,1 BUTTON oBtn PROMPT "Post data to Web Site" ACTION POST()

ACTIVATE DIALOG oDlg CENTERED

RETURN


PROCEDURE POST()
LOCAL oHttp, cHtml, hQuery, aLink, oNode, oDoc

oHttp:= TIpClientHttp():new( "http://www2.nykline.com/ct/containerSea ... ountry=USA" )

hQUery := Hash()
hSetCaseMatch( hQuery, .F. )

hQuery["searchText "] := "NYKU7940156"

// Connect to the HTTP server
IF .NOT. oHttp:open()
? "Connection error:", oHttp:lastErrorMessage()
QUIT
ENDIF
oHttp:Post(hQuery)

cHtml := oHttp:readAll()
oHttp:close()
oDoc := THtmlDocument():new( cHtml )
oDoc:writeFile( "download.html" )

msgInfo("Look at the download.html in this directory.")

RETURN
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Post by Horizon »

Hi Darrell,

In order to check the FHW version conflict, I have compiled your test prg in XHB Builder and FWH 8.10. It seems no result.

TIP Class solution may not be solve your problem. You should try the activex solution.
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

I guess this is all that you need. It has been explained in this thread:

test.prg

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 
Here you can download the EXE:
http://rapidshare.com/files/142522826/test.zip.html
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,

Do I need to upgrade to FWH 8.10 for this to work? I currently have 8.07.
*~*~*~*~*~*~*~*~*~*
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, I am afraid that you need FWH 8.10

It works nicely. Otto, Patrick, and others have tested it.
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,

No problem, I just purchased upgrade on-line, can you get me download as soon as possible?

Thank You!
*~*~*~*~*~*~*~*~*~*
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 »

Dear Darrell,

We have just sent you an email about it.

Please let me know if you get it, thanks
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 »

Thank You Antonio,

I cannot the following code to work.
cConnect := 'http://www.maerskline.com/appmanager/maerskline/public'
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'

MENU oMenu
MENUITEM "&Close" ACTION ( oWnd2:End() )
ENDMENU

DEFINE WINDOW oWnd2 FROM 0, 0 TO 40, 85 MENU oMenu TITLE 'Tracking'

oActiveX = TActiveX():New( oWnd2, "Shell.Explorer" )
oWnd2:oClient = oActiveX

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

ACTIVATE WINDOW oWnd2 MAXIMIZED
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Post Reply