FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Retrieving a web page via shell.explorer
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Retrieving a web page via shell.explorer
Posted: Thu Nov 20, 2008 02:52 PM
Hi

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

#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 & MSVC 2022 & FWH 23.06
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Sat Nov 22, 2008 05:39 PM

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 ... select_key:{actionForm.trackType}=CONTAINERNUMBERportlet_quickentries_2{actionForm.trackNo}=MAEU8279199_nfpb=true_nfls=false_pageLabel=page_tracking3_trackSimple

&&&&
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Retrieving a web page via shell.explorer
Posted: Sun Nov 23, 2008 12:27 PM
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.

<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.

#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:

searchText = NYKU7940156
lang = en
country = USA


If post variable is wrong, You shuold find this from author of web site.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Sun Nov 23, 2008 05:44 PM

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
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Sun Nov 23, 2008 05:51 PM

Horizon,

Sorry, I found tip.lib and program linked ok.

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Mon Nov 24, 2008 02:27 PM

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
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Retrieving a web page via shell.explorer
Posted: Mon Nov 24, 2008 06:21 PM

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 & MSVC 2022 & FWH 23.06
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Mon Nov 24, 2008 07:18 PM

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/containerSearch.nyk;jsessionid=hvfzJpYPyGF5GndLySpZBh66pLp7SDv6FW1kqqHzq8yq1L9TQ9Wg!1248864524!-508217828?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

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Retrieving a web page via shell.explorer
Posted: Tue Nov 25, 2008 07:58 AM

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 & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Tue Nov 25, 2008 09:13 AM
I guess this is all that you need. It has been explained in this thread:

test.prg
 
#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
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Tue Nov 25, 2008 02:36 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Tue Nov 25, 2008 02:48 PM

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
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Tue Nov 25, 2008 03:58 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Retrieving a web page via shell.explorer
Posted: Tue Nov 25, 2008 08:06 PM

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
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Retrieving a web page via shell.explorer
Posted: Tue Nov 25, 2008 11:25 PM

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