沙漏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

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型