On this Mistar website I'm trying to make a request from an iOS app using NSURLSession that loads the website above in the background, passes two strings for username and password into the <input>'s and then lets me access the logged in page.

Here's the relevant HTML, it's a table with two input forms, pin which is a username and then the password:

<div class="widgetbdy" style="border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;">
        <table border="0" cellpadding="2" cellspacing="0" class="txtin3" style="width:100%; border-collapse: collapse">
            <tbody><tr style="height:10px;">
                <td colspan="2" style="height:10px;"></td>
            </tr>
            <tr style="padding-top:4px;">
                <td align="right" style="width:30%;">

                        <b><label for="ID" id="lblID">ID</label>:</b>

                </td>
                <td align="left">
                    <input class="txtin" id="Pin" name="Pin" onfocus="clearmessages()" style="width:175px;" type="text" value="">
                </td>
            </tr>
            <tr>
                <td align="right" style="width:30%;">
                    <b><label for="Password" id="lblPassword">Password</label>:</b>
                </td>
                <td align="left">
                    <input class="txtin" id="Password" name="Password" onfocus="clearmessages()" style="width:175px;" type="password" value="">
                </td>
            </tr>
            <tr>
                <td id="loginerrormsg" align="center" colspan="2">
                    <img id="imgwait" src="./Student Portal_files/ajax-loader.gif" width="20" height="20" alt="" style="display:none;">
                    <div id="msg1" style="display: none;" class="error"><label for="idandpasswordrequired" id="lblidandpasswordrequired">ID and Password Required</label></div>
                    <div id="msgdisplay" style="display: none;">
                    <div id="msgmessage" style="text-align:center; padding-bottom:10px;" class="error"></div>
                    </div>
                </td>
            </tr>
            <tr>
                <td align="right" colspan="2">
                    <input id="LoginButton" style="visibility: visible" type="button" value="Log In">
                </td>
            </tr>

            <tr style="height:10px;">
                <td colspan="2" style="height:10px;"></td>
            </tr>
        </tbody></table>
    </div>
有帮助吗?

解决方案

You can do this by creating offscreen UIWebView and little javascript that fill required field and execute form submit.

Or another way, if site not so hard implemented you can make POST request to auth URL directly without html form

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top