如何使用jsoup post请求提交表单电子邮件和密码

dgiusagp  于 2021-07-05  发布在  Java
关注(0)|答案(0)|浏览(350)

我想连接到hello everyone墙纸网站并从那里输入我的收藏夹。但首先我必须登录。当我输入用于登录的信息时,它们不起作用。我能做什么?我在logcat中得到了这个站点的文档,但是同样的站点又出现了。我不知道如何登录请帮助。

private class AsyncTaskParse extends AsyncTask<Document, Document, Document>{
    String urlsign="https://wallpapercave.com/signin";
    String urlfav= "https://wallpapercave.com/favorites";

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        mProgressDialog = new ProgressDialog(MainActivity.this);
        mProgressDialog.setMessage("Loading..");
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.show();
    }

    @Override
    protected Document doInBackground(Document... params) {
        try {

            Connection.Response loginFormResponse = Jsoup.connect(urlsign).timeout(30000).maxBodySize(0)
                    .method(Connection.Method.GET)
                    .execute();

            Document login = Jsoup.connect(urlsign).timeout(30000).maxBodySize(0)
                    .data("email", "my mail adress")
                    .data("password", "my pasword")
                    .cookies(loginFormResponse.cookies())
                    .post();

            return  login;

        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Document result) {
        Log.d("TAG_DOCUMENT", "" + result);
        mProgressDialog.dismiss();
    }
}

登录窗体

<div id="mform">
  <form action="/login-process?redirect=" method="post" id="singinform">
    <input type="text" id="email" name="email" placeholder="Username or e-mail" value="">
    <input type="password" id="password" name="password" placeholder="Password">

    <input type="submit" value="Sign in">

    <div>
      <p class="remember">Forgot your password? <a href="/passwordrecovery">Recover your password!</a></p>
      <p class="remember">Don't have an account yet? <a href="/signup?redirect=">Create an account!</a></p>
    </div>
  </form>
  <br class="clear">
</div>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题