Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
KeKe12030 committed Feb 6, 2020
1 parent 36e1ac9 commit a86be0c
Show file tree
Hide file tree
Showing 16 changed files with 789 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="F:/JavaSpace/jcq-coolq-1.2.7.jar"/>
<classpathentry kind="lib" path="F:/JavaSpace/jsoup-1.12.1.jar"/>
<classpathentry kind="lib" path="F:/JavaSpace/htmlunit-2.25-OSGi.jar"/>
<classpathentry kind="lib" path="F:/JavaSpace/json-20180813.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>KQPlugin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/cn/mcplugin/kqjcq/Main.java=UTF-8
encoding//src/cn/mcplugin/kqjcq/SickWebSite.java=UTF-8
13 changes: 13 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# rbqrobort
### 这是一个RBQ机器人插件,配套使用酷Q,基于JCQ插件,以及JCQ框架
#### 主要功能:
+ ##### 获取实时全国新型冠状肺炎地区分布地图和地区确诊信息
+ ##### 为武汉加油点赞(触发词:武汉 && (加油 / 点赞)
+ ##### 发送已经保存过的全国热点迁移地图
#### 因为是自产自销的插件,所以代码可读性和性能比较差,见谅。
#### 需要用到的目录也是绝对定位的
###### (C:\\Users\\Administrator\\Desktop\\image)
###### (C:\\Users\\Administrator\\Desktop\\image\\wh)

###### 更新日期:2020-01-27
Binary file added bin/cn/mcplugin/kqjcq/JsonInfo.class
Binary file not shown.
Binary file added bin/cn/mcplugin/kqjcq/MCPlugin.class
Binary file not shown.
Binary file added bin/cn/mcplugin/kqjcq/Main.class
Binary file not shown.
Binary file added bin/cn/mcplugin/kqjcq/SickWebSite.class
Binary file not shown.
Binary file added bin/cn/mcplugin/kqjcq/WHComeOn.class
Binary file not shown.
1 change: 0 additions & 1 deletion rbqrobort
Submodule rbqrobort deleted from 3610f0
77 changes: 77 additions & 0 deletions src/cn/mcplugin/kqjcq/JsonInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package cn.mcplugin.kqjcq;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.HTTP;
import org.json.JSONArray;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@SuppressWarnings("all")
public class JsonInfo implements Runnable{
public static String jsonStr = null;
final static String api = "https://www.tianqiapi.com/api?version=epidemic&appid=23035354&appsecret=8YvlPNrz";
public static void main(String[] args) {
getDocument();
System.out.println(getGlobalInfo());
}

public String getCityInfo(String city) {return null;}

public static String getGlobalInfo() {
JSONObject j = new JSONObject(jsonStr);
JSONObject arr = j.getJSONObject("data");
String finalStr = "数据更新至:"+arr.getString("date")+"\n"
+"确诊病例:"+arr.getInt("diagnosed")+"\n"
+"疑似病例:"+arr.getInt("suspect")+"\n"
+"治愈人数:"+arr.getInt("cured")+"\n"
+"死亡病例:"+arr.getInt("death");


return finalStr;



}

public static void getDocument() {
//实例化defaultHttpClient
DefaultHttpClient hc=new DefaultHttpClient();
try {
//实例化post方式访问并且把路径放入
HttpPost httppost=new HttpPost(api);
//把需要的参数传入
//执行访问返回resp
HttpResponse resp=hc.execute(httppost);
//获取访问的结果
HttpEntity entity=resp.getEntity();
//把返回的结果转成字符串
jsonStr = EntityUtils.toString(entity);

} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}//运行完后执行
finally {
hc.getConnectionManager().shutdown();
}

}

@Override
public void run() {
getDocument();
try {
Thread.sleep(1000*600);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
82 changes: 82 additions & 0 deletions src/cn/mcplugin/kqjcq/MCPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package cn.mcplugin.kqjcq;

import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class MCPlugin {
public void htmlTurnImage(String html) throws Exception {
JEditorPane ed = new JEditorPane(html);
ed.setSize(200,200);

//create a new image
BufferedImage image = new BufferedImage(ed.getWidth(), ed.getHeight(),
BufferedImage.TYPE_INT_ARGB);

//paint the editor onto the image
SwingUtilities.paintComponent(image.createGraphics(),
ed,
new JPanel(),
0, 0, image.getWidth(), image.getHeight());
//save the image to file
ImageIO.write((RenderedImage)image, "jpg", new File("F:\\Desktop\\new.jpg"));
}
public String getHtml() throws IOException {
String a = null;
String b = null;
String url = "https://3g.dxy.cn/newh5/view/pneumonia";
Document doc = Jsoup.connect(url)
.header("Accept", "*/*")
//.header("Connection:", "keep-alive")//如果是这种方式,这里务必带上
.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36")//伪装Chrome浏览器
.timeout(30000)//超时时间30秒
.get();
Elements es = doc.getElementsByTag("p");
for(Element e : es) {
if(e.className().contains("mapTitle___"));
a = e.toString();
System.out.println(a);
break;
}
for(Element e : es) {
if(e.className().contains("confirmedNumber")) {
b = e.toString();
System.out.println(b);
break;
}
}
return a+"\n"+b;

}
public static void main(String[] args) throws Exception {
MCPlugin mc = new MCPlugin();
//String c = mc.getHtml();
//mc.htmlTurnImage(c);
JEditorPane ed = new JEditorPane(new URL("https://www.mcplugin.cn"));
ed.setSize(2000,2000);

//create a new image
BufferedImage image = new BufferedImage(ed.getWidth(), ed.getHeight(),
BufferedImage.TYPE_INT_ARGB);

//paint the editor onto the image
SwingUtilities.paintComponent(image.createGraphics(),
ed,
new JPanel(),
0, 0, image.getWidth(), image.getHeight());
ImageIO.write((RenderedImage)image, "png", new File("F:\\Desktop\\html.png"));

}
}
Loading

0 comments on commit a86be0c

Please sign in to comment.