标题: [精]2011年虎绿林开站以来沙雕网友究竟发了多少帖子?
时间: 2019-07-06发布,2019-07-06修改
时间 发帖量
2011年1月 19
2011年2月 193
2011年3月 45
2011年4月 0
2011年5月 702
2011年6月 1108
2011年7月 1532
2011年8月 1755
2011年9月 843
2011年10月 651
2011年11月 269
2011年12月 404
2012年1月 474
2012年2月 605
2012年3月 425
2012年4月 761
2012年5月 715
2012年6月 852
2012年7月 1078
2012年8月 1005
2012年9月 471
2012年10月 693
2012年11月 663
2012年12月 1062
2013年1月 1143
2013年2月 1245
2013年3月 961
2013年4月 1023
2013年5月 924
2013年6月 1063
2013年7月 1256
2013年8月 1518
2013年9月 759
2013年10月 872
2013年11月 808
2013年12月 912
2014年1月 890
2014年2月 767
2014年3月 617
2014年4月 608
2014年5月 677
2014年6月 714
2014年7月 1215
2014年8月 1060
2014年9月 657
2014年10月 663
2014年11月 616
2014年12月 633
2015年1月 615
2015年2月 754
2015年3月 623
2015年4月 570
2015年5月 564
2015年6月 616
2015年7月 882
2015年8月 997
2015年9月 612
2015年10月 414
2015年11月 410
2015年12月 454
2016年1月 365
2016年2月 294
2016年3月 265
2016年4月 307
2016年5月 283
2016年6月 300
2016年7月 411
2016年8月 363
2016年9月 278
2016年10月 346
2016年11月 258
2016年12月 319
2017年1月 326
2017年2月 374
2017年3月 291
2017年4月 231
2017年5月 264
2017年6月 246
2017年7月 265
2017年8月 268
2017年9月 239
2017年10月 220
2017年11月 248
2017年12月 190
2018年1月 186
2018年2月 156
2018年3月 198
2018年4月 214
2018年5月 240
2018年6月 223
2018年7月 196
2018年8月 192
2018年9月 152
2018年10月 138
2018年11月 118
2018年12月 167
2019年1月 134
2019年2月 101
2019年3月 129
2019年4月 156
2019年5月 165
2019年6月 167
2019年7月 39
@Autowired
private LaohuMapper laohuMapper;
@org.junit.Test
/**
* 将网页信息存到数据库 最笨的方式
*/
public void huTest() {
// 遍历页码 使用虎林自带的json格式
for (int i = 1; i <= 2775; i++) {
// Http这个是nutz jar包里封装好的工具
Response response = Http.get("https://hu60.cn/q.php/bbs.forum.0." + i + ".json");
// 解说json化 并且取出各种信息
JSONObject result = (JSONObject) JSONObject.parse(response.getContent());
JSONArray topicList = (JSONArray) result.get("topicList");
for (Object o : topicList) {
JSONObject jo = (JSONObject) o;
// 这个操作去除字符串中的emoji表情 MySQL默认编码不支持emoji 1.改编码 2.直接去掉 这里采用后者
String title = jo.get("title").toString().replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "");
System.out.println(title);
String view = jo.get("read_count").toString();
String count = jo.get("reply_count").toString();
String uinfo = jo.get("uinfo").toString();
JSONObject parse = (JSONObject) JSONObject.parse(uinfo);
// topic_id也是帖子链接URL的关键一部分下面备用
String topicId = jo.get("topic_id").toString();
String locked = jo.get("locked").toString();
String name = null;
try {
Laohu laohu = new Laohu();
if ("0".equals(locked.trim())) {
JSONObject content = (JSONObject) JSONObject.parse(Http.get("https://hu60.cn/q.php/bbs.topic." + topicId + ".json").getContent());
JSONObject tContents = (JSONObject) content.getJSONArray("tContents").get(0);
String context = tContents.get("content").toString().replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "");
laohu.setContent(context);
}
name = parse.get("name") == null ? "" : parse.get("name").toString();
Long time = Long.valueOf(jo.get("ctime").toString()) * 1000;
// 实体类中开启了Lombok注解 @Accessors(chain = true) 链式set
laohu.setTitle(title)
.setVisit(view)
.setTime(new Date(time))
.setCount(Integer.valueOf(count))
.setAuthor(name);
// 插入记录 mybatis plus自带方法
laohuMapper.insert(laohu);
} catch (Exception e) {
e.printStackTrace();
continue;
}
}
}
}
『回复列表(24|隐藏机器人聊天)』