求问,怎么样一次做两次正则表达式匹配?
发布网友
发布时间:2022-05-26 13:06
我来回答
共1个回答
热心网友
时间:2023-10-18 13:39
import java.io.*;
import java.net.*;
public class Yugi {
public static String resolveHTML(String spec, String charsetName) {
try {
URL url = new URL(spec);
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
InputStreamReader isr = new InputStreamReader(huc.getInputStream(), charsetName);
BufferedReader br = new BufferedReader(isr);
StringBuilder builder = new StringBuilder();
String line = null;
while (null != (line = br.readLine())) {
builder.append(line);
}
br.close();
isr.close();
huc.disconnect();
return builder.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args){
int page = 1;
String prev= "ht防止tp://v.m.zjxuexi.com/a/archiver/?tid-21.html&page=";
String url = prev + page;
String str = "";
String result = "";
while((result = resolveHTML(url, "utf-8")).length() != str.length()){
url = prev + (++page);
str = result;
System.out.println(result);
}
}
}
追问这和我的问题好像没什么关系
追答你不是要获取每个页面的内容么
你不是要取么
你之前的那几个问题不都透露了么
还来忽悠我
我打印出来3行,说明就是最大页码了,还要别人来说明
真是一点觉悟都没有,采纳即可
不采纳,就加你到诚信的黑名单