Well I got part way (doncha just luv the DOM!)

LOCAL loIE as InternetExplorer.Application
LOCAL oDoc as InternetExplorer.Document
LOCAL oFm as html.form
loIE = CREATEOBJECT("InternetExplorer.Application")
? loIE.Navigate2("http://www.universalthread.com";)
oDoc = loIE.Document
oFm = oDoc.getElementById("Form1")
* oUID = oFm.getelementsbyname("Username")  && nope
oUID = oDoc.getelementsbyname("Username") && OK - but it returns a list - so:
oUID1 = oUID.item(0)
?oUid1.value                                && empty
oUid1.value = "fooYou"
?oUid1.value                                && fooYou
* oPW = oFm.getelementsbyname("Password")   && nope
oPW = oDoc.getelementsbyname("Password")    && OK - but ...
oPW1 = oPW.item(0)
?oPW1.value                                 && empty
oPW1.value='pw'
?oPW1.value                                 && pw
loIE.Visible = .T.                          && like I told ya'
?oFm.submit                                 && NO
?oFm.submit()                               &&
oFm.submit()                                && WAY
oDoc.getElementById('Form1').submit()       &&
oDoc.getElementById('Form1').submit         &&
oFm = oDoc.getElementById("Form1")          && JOSE
oFm.submit                                  &&
loIE.Quit
CLOSE ALL
CLEAR ALL
RELEASE ALL
CLEAR

On 07/02/2014 11:48, Joe Yoder wrote:
Thanks guys for the input so far!  I found some very basic sample code but
haven't succeeded in logging in.  The execution fails on the line that
attempts to set the username.  I suspect that the HTML or the site has
changed since the code was written but I haven't figured out how to get
around it.  Here is the code if anyone cares to try it and tell me what
needs to change:

#define CR CHR(13)

LOCAL ;
loIE as InternetExplorer.Application, ;
llSuccess as Logical, ;
x as String

* Create an instance of IE
loIE = CREATEOBJECT("InternetExplorer.Application")
loIE.Visible = .T.

* Tell IE to load a page
llSuccess = loIE.Navigate("http://www.universalthread.com";)

* Wait for IE to do it
llSuccess = lWait( loIE )

* Show the names of the forms:
x = "Forms:"
For lnForm = 0 to loIE.Document.forms.length - 1
   x = x + TRANSFORM(lnForm) + ": " +
TRANSFORM(loIE.Document.forms(lnForm).name)
EndFor
x = x + CR
? x

* Fill in one of the forms
loIE.Document.Forms.form1("login").Username.Value = "foo"  && Fails with
"Member FORM1 does not evaluate to an object"
loIE.Document.Forms("login").Password.Value = "poo"
loIE.Document.Forms(0).Submit()
llSuccess = lWait( loIE )

* Look at all of the objects.
* all(0) represents everything,
* 1-N are contained objects some of which are containers themselves,
* so the same thing may apear in different .all(x)'s
x = x + "All Objects:"
For lnObj = 0 to loIE.Document.all.length - 1
loObj = loIE.Document.all( lnObj )
x = x + TRANSFORM(lnObj) + ": " + TRANSFORM(Substr(loObj.innerhtml, 1, 20))
x = x + TRANSFORM(loObj.TagName) + ": " + TRANSFORM(loObj.innertext)
EndFor

* Close IE.
* You can leave it open, doesn't seem to be a problem,
* unless .visible=.f. then it is harder to close cuz you cant see the X.
loie.Quit

* save and display results
STRTOFILE(x, "WebResult.txt")
MODIFY FILE WebResult.txt NOWAIT
Return



******************************
Function lWait( toIE )
* Wait for IE to process what you told it too.
* There has got to be a simpler way to do this.

DECLARE Sleep IN Win32API INTEGER nMilliseconds

Local ;
ltStartTime, ;
ltTimeOut, ;
lcCheckThis, ;
llRet

ltStartTime = Datetime()
ltTimeOut = ltStartTime + 60

DO WHILE (Datetime() < ltTimeOut ) ;
AND type( "toIE.document" ) <> "O"
=Sleep(1000)
EndDo
DO WHILE (Datetime() < ltTimeOut ) ;
AND toIE.busy
=Sleep(1000)
ENDDO
DO WHILE (Datetime() < ltTimeOut ) ;
and type( "toie.document.readystate" ) <> "C"
=Sleep(1000)
ENDDO
DO WHILE (Datetime() < ltTimeOut ) ;
and toie.document.readystate <> "complete"
=Sleep(1000)
ENDDO

llRet = Datetime() < ltTimeOut
If !llREt
toie.Stop()
EndIf

RETURN llRet



On Thu, Feb 6, 2014 at 11:57 PM, AndyHC <a...@hawthorncottage.com> wrote:

.. or search Ed's archives for 'screen scraping' or 'xmlhttp'


On 07/02/2014 03:07, Alan Bourke wrote:

On Thu, Feb 6, 2014, at 07:46 PM, Joe Yoder wrote:

  Any pointers on how to proceed will be welcome.
  Check if they publish an API. If not, Google 'web scraping'.
[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/52f606c3.9080...@hawthorncottage.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to