0

so here is the thing, i have this block of code:

<form action="Login.cfm" method="POST" name="login">

    <h1>Logga in</h1>

    <div class="form-group">
        <label>E-post</label>
        <input type="text" name="user_email" class="form-control" value="">
    </div>

    <div class="form-group">
        <label>Lösenord</label>
        <input type="password" class="form-control" name="user_password">
    </div>


    <input type="HIDDEN" name="action" value="login_nowin">

    <div class="row mb-3">
        <div class="col-md-6 mb-3">
            <input type="SUBMIT" class="btn btn-primary btn-login" value="Logga in" />
        </div>
        <div class="col-md-6 text-md-right">
            <a href="?startli=1" class="btn btn-linkedin"><span class="sr-only">Login with LinkedIn</span></a>
        </div>
    </div>

    <p>Har du glömt ditt lösenord? <a href="login_email.cfm">Get a reset link sent to you by e-mail.</a></p>

    <p>Ny användare? <a href="Register.cfm">Klicka här</a>!</p>
</form>

I am using jsoup to log in and create a cookie so i can keep a connection for the sites i am navigating. It is like that:

Connection.Response login =
            Jsoup.connect("https://myework.eworkgroup.com/Login.cfm")
                    .data("user_email","an email")
                    .data("user_password","a password")
                   .data("div.btn btn-primary btn-login", "Logga in")
                    .data("action","login_nowin")
                    .cookies(initial.cookies())
                    .method(Connection.Method.POST)
                    .execute();

I cannot connect and i think the problem is that there is no name or id for the button.

Does anyone have an idea if it is a different problem or how to solve it?

Thanks in advance!

cody
  • 11,045
  • 3
  • 21
  • 36

1 Answers1

0

You can use FormElement in this case, when you don't have the name.

Similar question have been asked before, check: How to fill a form with Jsoup?

And here's additional info about FormElement: https://jsoup.org/apidocs/org/jsoup/nodes/FormElement.html

GamingFelix
  • 239
  • 2
  • 10