资源简介
数据来源:http://219.140.162.169:8800/rw4/report/fa02.asp
jdk版本1.7以上
代码片段和文件信息
package model;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import util.SaveData;
public class Client {
public static String sendPost(String url String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = ““;
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty(“accept“ “*/*“);
conn.setRequestProperty(“connection“ “Keep-Alive“);
conn.setRequestProperty(“user-agent“
“Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 10.0; WOW64; Trident/7.0)“);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream() “gb2312“));
String line;
while ((line = in.readLine()) != null) {
// line.getBytes(“gb2312“);
// System.out.println(line);
result += line;
}
} catch (Exception e) {
System.out.println(“发送 POST 请求出现异常!“ + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return result;
}
public static void main(String[] args) throws InvalidFormatException IOException {
String url = “http://219.140.162.169:8800/rw4/report/ma02.asp“;
String param = ““;
SaveData sd = new SaveData();
System.out.println(“请输入需要爬取站点名:“);
System.out.println(“寸滩“);
Scanner sc = new Scanner(System.in);
new Scanner(System.in).next();
String sitename = sc.nextLine();
System.out.println(“请输入起始年份:“);
int bnian = sc.nextInt();
System.out.println(“请输入终止年份:“);
int enian = sc.nextInt();
int finish;
java.text.DecimalFormat df = new java.text.DecimalFormat(“#.0000“);
int rate = 0;
int maxri = 0;
int byue = 1 bri = 1 bshi = 8;
int eyue = 12 eri = 31 eshi = 8;
int nian = bnian yue = byue ri = bri shi = bshi;
int beijian = 0;
for (int ni = bnian; ni <= enian; ni++) {
for (int yi = byue; yi <= 12; yi++) {
if (yi == 2) {
if ((ni % 4 == 0 && ni % 100 != 0) || (ni % 400 == 0)) {
maxri = 29;
beijian = 29;
} else {
maxri = 28;
beijian = 28;
}
} else if (yi == 1 || yi == 3 || yi == 5 || yi == 7 || yi == 8 || yi == 10 || yi == 12) {
maxri = 31;
beijian = 31;
} el
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 955 2017-04-04 11:27 CollectFlowData\.classpath
文件 13 2017-04-04 12:06 CollectFlowData\.git\COMMIT_EDITMSG
文件 307 2017-04-04 13:10 CollectFlowData\.git\config
文件 73 2017-04-04 11:43 CollectFlowData\.git\desc
文件 23 2017-04-04 11:43 CollectFlowData\.git\HEAD
文件 478 2017-04-04 11:56 CollectFlowData\.git\hooks\applypatch-msg.sample
文件 896 2017-04-04 11:56 CollectFlowData\.git\hooks\commit-msg.sample
文件 189 2017-04-04 11:56 CollectFlowData\.git\hooks\post-update.sample
文件 424 2017-04-04 11:56 CollectFlowData\.git\hooks\pre-applypatch.sample
文件 1642 2017-04-04 11:56 CollectFlowData\.git\hooks\pre-commit.sample
文件 1348 2017-04-04 11:56 CollectFlowData\.git\hooks\pre-push.sample
文件 4951 2017-04-04 11:56 CollectFlowData\.git\hooks\pre-reba
文件 544 2017-04-04 11:56 CollectFlowData\.git\hooks\pre-receive.sample
文件 1239 2017-04-04 11:56 CollectFlowData\.git\hooks\prepare-commit-msg.sample
文件 177 2017-04-04 11:43 CollectFlowData\.git\hooks\README.sample
文件 3610 2017-04-04 11:56 CollectFlowData\.git\hooks\update.sample
文件 5054 2017-04-04 12:58 CollectFlowData\.git\index
文件 113 2017-04-04 11:43 CollectFlowData\.git\info\exclude
文件 516 2017-04-04 12:58 CollectFlowData\.git\logs\HEAD
文件 516 2017-04-04 12:58 CollectFlowData\.git\logs\refs\heads\master
文件 187 2017-04-04 11:56 CollectFlowData\.git\logs\refs\remotes\origin\HEAD
文件 2852 2017-04-04 12:57 CollectFlowData\.git\ob
文件 2847 2017-04-04 12:57 CollectFlowData\.git\ob
文件 55 2017-04-04 12:06 CollectFlowData\.git\ob
文件 75 2017-04-04 12:06 CollectFlowData\.git\ob
文件 2852 2017-04-04 12:57 CollectFlowData\.git\ob
文件 49 2017-04-04 12:06 CollectFlowData\.git\ob
文件 53 2017-04-04 12:06 CollectFlowData\.git\ob
文件 2811 2017-04-04 12:05 CollectFlowData\.git\ob
文件 2815 2017-04-04 12:05 CollectFlowData\.git\ob
............此处省略12663个文件信息
评论
共有 条评论