Android 通过okhttp + jsoup 爬虫爬取网页小说
效果图
1.准备工作
测试地址:http://www.tlxs.net
第三方依赖:
implementation ‘com.squareup.okhttp3:okhttp:4.10.0’
implementation ‘org.jsoup:jsoup:1.15.3’
implementation ‘com.github.bumptech.glide:glide:4.14.2’
2.通过okhttp获取 html数据
//获取okhttp对象
OkHttpClient client = getOkHttpClient();
Request request = new Request.Builder()
.url(address)
.build();
//获取请求返回数据
Response response = client.newCall(request).execute();
//回调输入流
InputStream inputStream = r