提问人:raghhav 提问时间:6/5/2019 更新时间:6/5/2019 访问量:43
如何仅监视静态 html 中的网页更改
How to monitor only the static html for changes in a web page
问:
我创建了一个应用程序来监控网页。诀窍是,当广告发生变化时,我的应用程序会检测到变化并触发警报。
如何解决这个问题?
这是我用于获取html的代码
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet( urlValue );
HttpResponse response;
try {
response = client.execute( get );
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream is = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader( is ) );
StringBuilder sb = new StringBuilder();
String result = null;
try {
while( ( result = reader.readLine() ) != null )
sb.append(result).append("\n");
} catch ( IOException e ) {
Log.e( "readFromUrl", e.getMessage() );
} finally {
try {
is.close();
} catch ( IOException e ) {
Log.e( "readFromUrl", e.getMessage() );
}
}
line = sb.toString();
is.close();
}
} catch( Exception e ) {
Log.e( "readFromUrl", e.getMessage() );
}
或者,jsoup 可能吗?
答: 暂无答案
评论