Retrieving a web page via shell.explorer

Postby Horizon » Thu Nov 20, 2008 2:52 pm

Hi

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

Code: Select all  Expand view

#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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby cdmmaui » Sat Nov 22, 2008 5: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}=CONTAINERNUMBER&portlet_quickentries_2{actionForm.trackNo}=MAEU8279199&_nfpb=true&_nfls=false&_pageLabel=page_tracking3_trackSimple
*~*~*~*~*~*~*~*~*~*
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 » 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.

Code: Select all  Expand view
<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  Expand view
#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  Expand view
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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

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

Postby cdmmaui » Sun Nov 23, 2008 5:51 pm

Horizon,

Sorry, I found tip.lib and program linked ok.
*~*~*~*~*~*~*~*~*~*
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 » Mon Nov 24, 2008 2: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Postby Horizon » Mon Nov 24, 2008 6: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

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

Postby Horizon » Tue Nov 25, 2008 7: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby Antonio Linares » Tue Nov 25, 2008 9:13 am

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

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

Here you can download the EXE:
http://rapidshare.com/files/142522826/test.zip.html
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 » Tue Nov 25, 2008 2: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
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 » Tue Nov 25, 2008 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby cdmmaui » Tue Nov 25, 2008 3: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
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 » Tue Nov 25, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 52 guests

cron