1 Star 0 Fork 0

水君/personal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Score.java 4.52 KB
一键复制 编辑 原始数据 按行查看 历史
水君 提交于 5年前 . update the codes
package demo;
import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Scanner;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.text.Document;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Score {
public static void main(String[] args) throws Exception{
Properties pro = new Properties();
pro.load(new FileInputStream("total.properties"));
@SuppressWarnings("rawtypes")
Enumeration fileName = pro.propertyNames();
String strKey = (String)fileName.nextElement();
String strValue = pro.getProperty(strKey);
double before_basic = Integer.parseInt(pro.getProperty("before"));
double base_basic = Integer.parseInt(pro.getProperty("base"));
double test_basic = Integer.parseInt(pro.getProperty("test"));
double program_basic = Integer.parseInt(pro.getProperty("program"));
double add_basic = Integer.parseInt(pro.getProperty("add"));
File input = new File("small.html");
File input1 = new File("all.html");
org.jsoup.nodes.Document doc = Jsoup.parse(input1,"UTF-8","https://www.mosoteach.cn/web/index.php?c=interaction&m=index&clazz_course_id=9E603F91-4AF8-11EA-9C7F-98039B1848C6");
org.jsoup.nodes.Document doc1 = Jsoup.parse(input,"UTF-8","https://www.mosoteach.cn/web/index.php?c=interaction&m=index&clazz_course_id=9E603F91-4AF8-11EA-9C7F-98039B1848C6");
Elements introw = doc.getElementsByAttributeValue("class", "interaction-row");
// System.out.println(introw);
Elements color = doc.select("span[style=color:#8FC31F;]");
Elements cy = doc.select("span[style=color:#8FC31F]");
Elements introw1 = doc1.getElementsByAttributeValue("class", "interaction-row");
// System.out.println(introw);
// Elements color1 = doc1.select("span[style=color:#8FC31F;]");
// Elements cy1 = doc1.select("span[style=color:#8FC31F]");
int before = 0;
int base = 0;
int test = 0;
int program = 0;
int add = 0;
int j = -1;
int num = 0;
int num1 = 0;
int k = 0;
for(int i = 0; i<introw.size() ; i++) {
if(j < color.size()-1) {
j++;
k = j;
String col = color.get(j).text();
//System.out.println(intname.get(i).text());
String regEx="[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(col);
String tri = m.replaceAll("").trim();
String tri1 = m.replaceAll("").trim();
if(tri!=null&&!tri.equals("")) {
num = Integer.valueOf(tri);
}
if(tri1!=null&&!tri1.equals("")) {
num1 = Integer.valueOf(tri);
}
}
if(j> color.size()-1) {
num = 0;
}
if(j>cy.size()-1) {
k = cy.size()-1;
}
Elements intname = doc.getElementsByClass("interaction-name");
Elements intname1 = doc1.getElementsByClass("interaction-name");
//System.out.println(intname.get(i).text());
String str = intname.get(i).text();
if(cy.get(k).text().contains("已参与")) {
if(intname.get(i).text().contains("课堂完成部分")) {
base += num;
}
else if(intname.get(i).text().contains("编程题")) {
program += num;
}
else if(intname.get(i).text().contains("附加题")) {
add += num;
}
else if(intname.get(i).text().contains("课堂小测")) {
test += num;
}
else if(intname.get(i).text().contains("课前自测")) {
before += num;
}
}
}
if (doc1 != null) {
Elements element = doc1.getElementsByAttributeValue("class", "interaction-row");
int y = 0;
for(int i=0;i<element.size();i++) {
if (element.get(i).child(1).child(0).toString().contains("课前自测")&&
element.get(i).child(1).child(2).toString().contains("color:#8FC31F")) {
Scanner s = new Scanner(element.get(i).child(1).child(2).children().get(0).children().get(10).text());
y = s.nextInt();
before =before + y;
}
}
}
double final_before = before/before_basic*100;
double final_base = base/base_basic*100;
double final_test = test/test_basic*100;
double final_program = program/program_basic*100;
double final_add = add/add_basic*100;
// System.out.println(final_before + " " + final_base + " " + final_test+ " " + final_program + " " +final_add);
double final_score = final_before*0.25+final_base*0.3*0.95+final_test*0.2+final_program*0.1+final_add*0.05+6;
System.out.println(final_score);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/L1n-9s5/personal.git
git@gitee.com:L1n-9s5/personal.git
L1n-9s5
personal
personal
master

搜索帮助