Skip to content

Commit

Permalink
修正不加入ES时空指针的问题 fixed #10
Browse files Browse the repository at this point in the history
  • Loading branch information
gsh199449 committed Dec 24, 2016
1 parent 0d0cacf commit 164e4ae
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
target
.idea
.iml
spider.iml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

------

[Readme in English](https://github.com/gsh199449/spider/tree/master/README-en.md)
[Readme in English](https://github.com/gsh199449/spider/tree/master/doc/README-en.md)

欢迎加入 `Gather Platform交流` QQ群 : 206264662

Expand Down
440 changes: 220 additions & 220 deletions README-en.md → doc/README-en.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

- 腾讯新闻:[精准时间模板](https://github.com/gsh199449/spider/blob/master/examples/news.qq.com.json)[自动探测时间模板](https://github.com/gsh199449/spider/blob/master/examples/news.qq.com_time_autodetect.json)
- 诗词网:[诗词名句网](https://github.com/gsh199449/spider/blob/master/examples/www.shicimingju.com.json)
- 中新网: [新闻抽取](https://github.com/gsh199449/spider/blob/master/examples/www.chinanews.com.json)
- 开源中国: [含有动态字段的抽取](https://github.com/gsh199449/spider/blob/master/examples/www.oschina.net.json)

2 changes: 2 additions & 0 deletions src/main/java/com/gs/spider/dao/ESClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public Client getClient() {
}

public boolean checkType(String index, String type, String mapping) {
if (client == null) return false;
if (!client.admin().indices().typesExists(new TypesExistsRequest(new String[]{index}, type)).actionGet().isExists()) {
LOG.info(type + " type不存在,正在准备创建type");
File mappingFile;
Expand Down Expand Up @@ -122,6 +123,7 @@ public boolean checkType(String index, String type, String mapping) {
}

public boolean checkIndex(String index, String mapping) {
if (client == null) return false;
if (!client.admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists()) {
File indexMappingFile;
try {
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/pages/panel/commons/editSpiderInfo.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@
<input type="text" class="form-control" id="publishTimeFormat" name="publishTimeFormat"
placeholder="发布时间模板" value="${spiderInfo.publishTimeFormat}">
</div>
<%--动态字段--%>
<div class="form-group" id="dynamicFields">
<button type="button" onclick="addDynamicField()" class="btn btn-info">添加动态字段
</button>
Expand Down Expand Up @@ -478,6 +479,7 @@
</div>
</c:forEach>
</div>
<%--静态字段--%>
<div class="form-group" id="staticFields">
<button type="button" onclick="addStaticField()" class="btn btn-info">添加静态字段
</button>
Expand Down Expand Up @@ -656,16 +658,19 @@
</div>
</body>
<script>
//JSON格式填充起始URL
var startUrls = [];
<c:forEach items="${spiderInfo.startURL}" var="url">
startUrls.push('${url}');
</c:forEach>
$('#startURL').val(JSON.stringify(startUrls));
//JSON格式填充回调地址
var callbackURL = [];
<c:forEach items="${spiderInfo.callbackURL}" var="url">
callbackURL.push('${url}');
</c:forEach>
$('#callbackURL').val(JSON.stringify(callbackURL));
// 检测上次编辑到一半的模板
var spiderInfo = localStorage["spiderInfo"];
if (spiderInfo != undefined) {
showModal("请注意", "检测到有尚未保存的爬虫模板,是否要继续编辑?", function () {
Expand Down

0 comments on commit 164e4ae

Please sign in to comment.