-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPCTest.java
71 lines (62 loc) · 1.42 KB
/
PCTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.test;
import java.util.List;
import java.util.Scanner;
import com.pojo.QuanZhi;
import com.util.DBhelper;
public class PCTest {
public static void main(String[] args) {
con();
}
public static void choice(){
System.out.println("请选择功能:");
System.out.println("1.爬虫功能");
System.out.println("2.查询功能");
PCQuanzhi pcq = new PCQuanzhi();
Scanner input = new Scanner(System.in);
int choice = input.nextInt();
switch(choice){
case 1:
String url = pcq.setUrl();
//获取用户输入的网页
int page = pcq.getPage(url);
//获取网页中的链接
pcq.getInfo(page,url);
//获取链接中的信息
if(pcq.getOneInfo()){
insert(pcq.quanzhilist);
}
else{
System.out.println("没有数据╮(╯_╰)╭");
}
break;
case 2:
QueryQuanzhi qqz = new QueryQuanzhi();
qqz.query();
break;
default:
break;
}
}
public static void insert(List<QuanZhi> list){
System.out.println("是否将数据添加到数据库中");
System.out.println("1.是");
System.out.println("2.否");
Scanner input = new Scanner(System.in);
int i = input.nextInt();
if(i==1)
DBhelper.insertQuanzhi(list);
else
return;
}
public static void con(){
Scanner input = new Scanner(System.in);
while(true){
choice();
System.out.println("是否继续?\n1.继续\n2.退出");
int a = input.nextInt();
if(a!=1){
break;
}
}
}
}