Newbie Alert

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mel Smith

    Newbie Alert

    Hi:

    I am a programmer (but in a language that is compiled into C code --
    then onto .obj and and then an executable -- xHarbour)

    I already am able to (programmatical ly) visit websites, and read (using
    IE and innerHTML) pages, then parse the textual contents of the page to
    glean the info I need. The websites I am visiting use Javascript 1.1

    Now, I need to emulate/enter a 'UserName' and 'Password', then produce a
    'Click' on the 'Submit' button all within my program.

    btw, I have ordered Javascript The Definitive Guide thru Amazon, and
    will get delivery within 5 days. In the meantime, do you have any hints on
    producing a 'click' on the Submit button.

    another btw, I have looked thru the Javascript Guide and haven't got
    much further.

    Anyway, it turns out that Javascript is very close in syntax to my
    xHarbour opensource language (see www.xharbour.org) and I'm anxious to
    learn!!

    Thanks !

    --
    Mel Smith


  • Henry

    #2
    Re: Newbie Alert

    On Aug 13, 4:12 am, Mel Smith wrote:
    <snip>
    I already am able to (programmatical ly) visit websites,
    and read (using IE and innerHTML) pages, then parse the
    textual contents of the page to glean the info I need.
    So that would be instantiating and externally driving an IE web
    browser COM component?
    The websites I am visiting use Javascript 1.1
    That is improbable. HTML LANGUAGE attributes in SCRIPT elements have
    very little use or meaning nowadays.
    Now, I need to emulate/enter a 'UserName' and 'Password',
    then produce a 'Click' on the 'Submit' button all within my
    program.
    <snip>
    In the meantime, do you have any hints on producing a 'click'
    on the Submit button.
    IE provides a - click - method on its submit button elements. Calling
    that will have the same (theoretically form submitting) consequences
    as a user clicking the button with some pointing device, except that -
    click -, - focus - and - blur - events will not necessarily occur on
    that element. The - submit - event of the containing form will be
    triggered.

    Calling the click method is going to be something like:-

    document.forms['formNameOrInde x'].elements['buttonNameOrIn dex'].click();

    - where - document - may need to be substituted with whatever form of
    property accessor gives you a referece to the document in your IE web
    browser component.

    See also:-

    <URL: http://jibbering.com/faq/faq_notes/form_access.html >

    Comment

    • Mel Smith

      #3
      Re: Newbie Alert

      Erwin & Henry:

      Thank you both for your guidance !

      I'll puzzle over your info today (while golfing), and respond tomorrow.

      (btw, it shows javascript 1.1 in the source code of all the pages
      provided . Hmmmm ..)

      (another btw. Yes, I instantiate IE and use

      Thanks again !

      -Mel Smith

      ------- a small part of my proggie is below ----
      // a small part of my program is below:

      TRY
      oIE := GetActiveObject ( "InternetExplor er.Application" )
      CATCH
      TRY
      oIE := CreateObject( "InternetExplor er.Application" )
      CATCH
      Alert( "ERROR ! IExplorer not available. [" + Ole2TxtError()+
      "]" )
      RETURN
      END
      END

      oIE:Visible := .F.


      cWebSite := "http://www.xxxx.org/xxxxxx/zzzzzzzz.aspx?I D="+someid

      oIE:Navigate(cW ebSite)

      while oIE:busy

      SecondsSleep(1. 00)

      ENDDO

      // Knowing the username and password (my own) I wish to 'submit'
      // the page after entering these input values, then 'click' on
      // the submit button

      // now carry on parsing and processing
      // then 'Loop' and do other stuff



      Comment

      • Henry

        #4
        Re: Newbie Alert

        On Aug 13, 3:31 pm, Mel Smith wrote:
        <snip>
        TRY
        oIE := GetActiveObject ( "InternetExplor er.Application" )
        CATCH
        TRY
        oIE := CreateObject( "InternetExplor er.Application" )
        CATCH
        Alert( "ERROR ! IExplorer not available. [" +
        Ole2TxtError()+ "]" )
        RETURN
        END
        END
        >
        oIE:Visible := .F.
        >
        cWebSite := "http://www.xxxx.org/xxxxxx/zzzzzzzz.aspx?I D="+someid
        >
        oIE:Navigate(cW ebSite)
        >
        while oIE:busy
        >
        SecondsSleep(1. 00)
        >
        ENDDO
        <snip>

        Given that, a recognisable equivalent of your intention using Windows
        Scripting Host and written in JScript would be:-

        var ieInstance, ieDocument, ieGlobal;
        var someid = 'XXXXX';
        ieInstance = new ActiveXObject(" internetexplore r.application") ;
        if(ieInstance){
        ieInstance.resi zable = true;
        ieInstance.widt h = 500;
        ieInstance.heig ht = 400;
        ieInstance.navi gate(
        "http://www.xxxx.org/xxxxxx/zzzzzzzz.aspx?I D="+someid
        );
        ieInstance.visi ble = true;
        while(ieInstanc e.readyState != 4){
        WScript.Sleep(1 00);
        }
        ieDocument = ieInstance.docu ment;
        ieGlobal = ieDocument.pare ntWindow;

        ieDocument.form s['FN'].elements['UN'].value = 'User Name';
        ieDocument.form s['FN'].elements['PW'].value = 'password';


        ieDocument.form s['FN'].elements['SB'].click();
        //or
        //ieDocument.form s['FN'].submit();
        }

        Substituting 'FN'. 'UN', 'PW', and 'SB' for the names of the FORM,
        user name field, password field and submit button respectively.

        Comment

        • Mel Smith

          #5
          Re: Newbie Alert

          Henry said:
          Given that, a recognisable equivalent of your intention using Windows
          Scripting Host and written in JScript would be:-
          >
          var ieInstance, ieDocument, ieGlobal;
          var someid = 'XXXXX';
          ieInstance = new ActiveXObject(" internetexplore r.application") ;
          if(ieInstance){
          ieInstance.resi zable = true;
          ieInstance.widt h = 500;
          ieInstance.heig ht = 400;
          ieInstance.navi gate(
          "http://www.xxxx.org/xxxxxx/zzzzzzzz.aspx?I D="+someid
          );
          ieInstance.visi ble = true;
          while(ieInstanc e.readyState != 4){
          WScript.Sleep(1 00);
          }
          ieDocument = ieInstance.docu ment;
          ieGlobal = ieDocument.pare ntWindow;
          >
          ieDocument.form s['FN'].elements['UN'].value = 'User Name';
          ieDocument.form s['FN'].elements['PW'].value = 'password';
          >
          >
          ieDocument.form s['FN'].elements['SB'].click();
          //or
          //ieDocument.form s['FN'].submit();
          }
          >
          Substituting 'FN'. 'UN', 'PW', and 'SB' for the names of the FORM,
          user name field, password field and submit button respectively.
          Henry:

          I'll give that a try tomorrow.

          -Mel Smith


          Comment

          Working...