android:webview获取网页登陆账号和密码

本文介绍了如何在Android的WebView中捕获并显示网页登录时的账号和密码信息,以百度登录页面为例,详细讲解了遇到的问题及解决办法,包括在何处截取页面信息,如何处理获取数据的时机,以及最终实现的代码示例。
摘要由CSDN通过智能技术生成

使用webview获取html页面信息

需求:抓取webview打开的页面中登陆信息,简单点说就是获取第三方的账号和密码。(咋一想,这尼玛有点坑啊,获取别人的信息,怎么都不太好吧。但是也得实现呀。。。)

本文将以抓取百度账号信息为例。(这尼玛也是一个坑。。。百度还是有一些安全措施的。自己挖的坑,笑着也要填完。)
这里写图片描述

下面开始正文

测试地址

const val TEST_URL = "http://www.baidu.com"

布局代码

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".WebviewActivity">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.constraint.ConstraintLayout
        android:id="@+id/constraint_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        app:layout_constraintVertical_bias="1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf=
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值