开发者

How to automate login with a webapp?

开发者 https://www.devze.com 2023-03-19 13:39 出处:网络
I\'m trying to log into a (what开发者_运维百科 I assume to be a) webapp and I get stuck trying to log into the website. Using WWW::Mechanize does work but in the responses from my post, content it pri

I'm trying to log into a (what开发者_运维百科 I assume to be a) webapp and I get stuck trying to log into the website. Using WWW::Mechanize does work but in the responses from my post, content it print nothing more than a couple HTML Javascript:

<HTML>

<SCRIPT Language=JAVAScript>

 var msgTimerID;

 var strForceLogOff = "false";

 function WindowOnLoad(){

    if ("false" == "true" && "false" == "false") 
        MerlinSystemMsg("",64);

    if ("false"=="true") 
        msgTimerID = window.setInterval("MerlinSystemMsg(10095,64)", 300000,'javascript');

 }

 function MyShowModal(){

     showModalDialog("", window, strFeatures);}

 function clearMsgInterval(){

    window.clearInterval(msgTimerID);

 }

 function WindowOnUnLoad(){

     if(top.frames(0).document.getElementById("OPMODE").value =="LOGOFF"){

         strFeatures = "width=1,height=1,left=1000,top=1000,toolbar=no,scrollbars=no,menubar=no,location=no,directories=no,status=yes,resizable=1";

         window.open("ForceLogOff.aspx","forcelogout",strFeatures);

     }

 }

 window.onbeforeunload = WindowOnUnLoad;

 window.onload = WindowOnLoad;

</SCRIPT>

<FRAMESET  ROWS="57px, *" BORDER=0 FRAMEBORDER=0  STYLE="background-color=transparent"> 

<FRAME TITLE="Service Desk Express Navigator" SRC="Options_split.aspx?NavigatorName=1065" NORESIZE>  

</HTML>

There is also this Frame Title that has the src:

 FRAME TITLE="Service Desk Express Navigator" SRC="options_nailogo.aspx" MARGINWIDTH=0 MARGINHEIGHT=0 NORESIZE scrolling=no

In general, how would I handle a response like this when the content is not the websites source, but mostly scripts?


That content is the website source :)

How WWW::Mechanize deals with FRAME SRC as a link:

Note that <FRAME SRC="..."> tags are parsed out of the the HTML and treated as links so this method works with them.

You'll want to use follow_link on that link.


See my answer to this related question. Both PhantomJS and Selenium are good tools for automating interactions with sites that rely heavily on Javascript to display the user interface.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号