如何在没有提交按钮的情况下使用Jsoup提交表单?

时间:2022-10-31 11:11:26

I have a site form that I want to submit. The problem is that the submit button of this site doesn't have a name.

我有一个我想提交的网站表单。问题是该站点的提交按钮没有名称。

Form html:

<form class="login" action="oauth" method="post" name="login">
    <input name="username" value="" id="username"/>
    <input name="password" type="password" id="password"/>
    <input class="button" type="submit" value="Login"/>
</form>

My current Java code

我目前的Java代码

Document response = Jsoup.connect(url)
                .data("username", "username")
                .data("password", "reallygoodpassword")
                .data("", "Login") //But how to tag the button here? 
                .post();

Or is this not possible with Jsoup? If not, is there an alternative way of filling out a form that would work on this?

或者这对Jsoup来说不可能吗?如果没有,是否有另一种填写表格的方法?

1 个解决方案

#1


0  

Try to submit the form from your favorite browser and see how it handles this case. Don't forget to show the Network tab from the developer tool of your browser.

尝试从您最喜欢的浏览器提交表单,看看它如何处理这种情况。不要忘记从浏览器的开发人员工具中显示“网络”选项卡。

Once you know how the browser handles this case, do the same in your code.

一旦您知道浏览器如何处理这种情况,请在代码中执行相同的操作。

#1


0  

Try to submit the form from your favorite browser and see how it handles this case. Don't forget to show the Network tab from the developer tool of your browser.

尝试从您最喜欢的浏览器提交表单,看看它如何处理这种情况。不要忘记从浏览器的开发人员工具中显示“网络”选项卡。

Once you know how the browser handles this case, do the same in your code.

一旦您知道浏览器如何处理这种情况,请在代码中执行相同的操作。