Jump to content

Modify HTML element


Recommended Posts

For example, this is the HTML of a textbox on a website.

<input type="text" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="" data-fv-field="username">

I want to go ahead and add in, 

style="display: hidden;"

From what I understand, I'm only able to add in HTML via _IEDocInsertHTML, but I'm not sure how to go about adding inside a specific tag.

Link to comment
Share on other sites

#include <ie.au3>

Local $browser = _IECreate('')

_IENavigate($browser,'http://www.autoitscript.com/forum/')
_IELoadWait($browser)

Local $html = _IEDocReadHTML($browser)
Local $new_html = StringReplace($html,"Forums","New Text")

_IEDocWriteHTML($browser,$new_html)

Hope this will give you the directions you need.

You can put the whole html line into the stringreplace.

Link to comment
Share on other sites

Not sure what I'm doing wrong =/

Local $UsernameOnline1 = InetRead("http://website.com/Username1.txt")
            Local $Username1 = BinaryToString($UsernameOnline1)

            Local $PasswordOnline1 = InetRead("http://website.com/Password1.txt")
            Local $Password1 = BinaryToString($PasswordOnline1)

            Local $browser = _IECreate("http://website.com/access/login/")

            _IELoadWait($browser)
                        Local $html = _IEDocReadHTML($browser)
            Local $new_html = StringReplace($html,"<input type='text' name='username' class='form-control'","<input type='text' name='username' class='form-control' style='display:none;'>")
            _IEDocWriteHTML($browser,$new_html)

            Local $LoginForm = _IEFormGetObjByName($browser, "login")
            Local $Username = _IEFormElementGetObjByName($LoginForm, "username")
            Local $Password = _IEFormElementGetObjByName($LoginForm, "password")



            _IEFormElementSetValue($Username, $Username1)
            _IEFormElementSetValue($Password, $Password1)

The textbox doesn't change =/

Link to comment
Share on other sites

In your first post the html had double quotes, you are trying to replace with single quotes.

Can we see the html?

Local $new_html = StringReplace($html,'<input type="text" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="" data-fv-field="username">','<input type="text" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="" data-fv-field="username" style="display: hidden;">')
Link to comment
Share on other sites

 

In your first post the html had double quotes, you are trying to replace with single quotes.

Can we see the html?

Local $new_html = StringReplace($html,'<input type="text" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="" data-fv-field="username">','<input type="text" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="" data-fv-field="username" style="display: hidden;">')

 

I tried doing that but it still didn't work out.

The site is NSFW so I don't think I can post the link to the website.

But here's the relevant HTML

<form name="login" id="login-form" class="box-login-form" method="post" action="/access/submit/">
                <h2>MEMBER LOGIN</h2>
                <div class="form">
                    <label for="username" class="input_label_username">Username or Email</label>
                    <input class="input_username" type="text" name="username" id="username" autofocus="autofocus" autocomplete="off" tabindex="1" data-validation="[NOTEMPTY, >=6]" data-validation-message="Username must contain more than 6 characters. No spaces.">
                    <label class="input-label-password" for="password">Password</label>
                    <input class="input_password" type="password" name="password" id="password" autocomplete="off" tabindex="2" data-validation="[NOTEMPTY, >=6, <=16]" data-validation-message="Password must contain between 6 and 16 characters">
                                        <div class="checkbox_box">
                        <input class="checkbox" type="checkbox" name="rememberme" id="rememberme" checked="checked">
                        <span>Remember Me</span>
                    </div>
                    <input class="btn-blue" type="submit" value="login now" tabindex="4">
                    <label>
                        <a class="forgot-password" href="/access/forgotpassword/">
                            Forgot Password?
                        </a>
                    </label>
                </div>
            </form>
Link to comment
Share on other sites

$URL = "http://www.website.com/"
$HTTP = ObjCreate("winhttp.winhttprequest.5.1")
$HTTP.Open("GET", $URL)
$HTTP.Send()
$HTTP.WaitForResponse()
$SourceHTML = $HTTP.Responsetext
$Statut = $HTTP.Status
If $Statut == 200 Then
    $NewSource = StringReplace($SourceHTML, '<input type="text" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="" data-fv-field="username">', '<input type="text" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="" data-fv-field="username"> style="display: hidden;"', Default)
    ConsoleWrite($SourceHTML & @LF)
EndIf

It works ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...