package d;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class Main {
public static void main(String[] args) {
try {
for (int k = 1; k <= 50; k++) {
URL url = new URL("http://sj.haliluya.com/Genesis_1_" + k + ".html");
try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
String s = "";
int i = 0;
while ((s = br.readLine()) != null) {
if (i == 85) {
String s2 = s.replaceAll("<ul class=\"jingRead\" id=\"song_list\">", "");
String s3 = s2.replaceAll("</ul>", "");
String s4 = s3.replaceAll("<li><span style='line-height:27px'>", "insert into t_HolyBible values ('创世记','" + k + "','");
String s5 = s4.replaceAll("</span><p>", "','");
String s6 = s5.replaceAll("<br/></p>", "\'\\);\n");
String s7 = s6.replaceAll("</li>", "");
System.out.println(s7);
//System.out.println(s);
Class.forName("org.sqlite.JDBC");
try (Connection c = DriverManager.getConnection("jdbc:sqlite:HolyBible2.sqlite3");
PreparedStatement ps = c.prepareStatement(s7);) {
int u = ps.executeUpdate();
System.out.println(u);
}
// }
// System.out.println("hw");
// try (FileWriter fw = new FileWriter("sql.txt", true)) {
// fw.write(s5);
// // System.out.println(s9);
//
// }
}
i++;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
拉去人家的网页数据信息java
最新推荐文章于 2024-08-25 18:04:08 发布