沙漏dan 2015-09-08 16:06 采纳率: 66.7%
浏览 4453

android向webview加载的页面中填充账号密码并且自动登陆遇到问题求解

    public static String LOGIN = "http://ui.ptlogin2.qq.com/cgi-bin/login?appid=46000101&style=8&lang=&low_login=1&hide_title_bar=1&hide_close_icon=1&daid=6&hln_css=http://mat1.gtimg.com/www/mb/images/logo244x100.png&s_url=http%3A%2F%2Fw.t.qq.com%2Ftouch";

final String tencent_url = LOGIN;
try {

            String js = FileUtils.readAssetsFile("oauthfortencent.js", TencentWeiboActivity.this);

            js = js.replace("%u%", tAccount).replace("%p%", tPassword);

            Document dom = Jsoup.connect(LOGIN).get();
            html = dom.toString();
            html = html.replace("</head>", js + "</head>")
                    .replace("action-type=\"submit\"", "action-type=\"submit\" id=\"submit\"");
            return html;
        } catch (Exception e) {
            e.printStackTrace();
        }
                mWebView.loadDataWithBaseURL("http://open.qq.com/", html, "text/html", "UTF-8", "");

js代码:

function fillAccount(){ document.getElementById("u").value = '%u%'; document.getElementById("p").value = '%p%'; document.getElementById("go").click(); }

原本网页应该是这样子的
图片说明
填充之后
图片说明
而且登录按钮不能被点击
我应该怎么弄才可以,谢谢

  • 写回答

1条回答 默认 最新

  • threenewbee 2015-09-08 17:26
    关注

    你的替换有问题,建议你注入js代码,实现填表。而不是直接替换html

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?