Skip to content

Commit 5296460

Browse files
committed
launch(CommonPool) {
crawOSChina(page) }
1 parent a91de54 commit 5296460

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
# saber
22
【 Spring Boot 实战开发】10 分钟快速构建一个自己的技术文章博客
3+
4+
5+
6+
### JVM启动参数
7+
8+
```-XX:-UseGCOverheadLimit -Xms256m -Xmx1024m```
9+
10+

src/main/kotlin/com/light/saber/service/CrawKnowledgeService.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.light.saber.dao.CrawSourceDao
44
import com.light.saber.dao.KnowledgeDao
55
import com.light.saber.model.Knowledge
66
import com.light.saber.webclient.CrawlerWebClient
7+
import kotlinx.coroutines.experimental.CommonPool
8+
import kotlinx.coroutines.experimental.launch
79
import org.jsoup.Jsoup
810
import org.jsoup.nodes.Document
911
import org.jsoup.nodes.Element
@@ -23,7 +25,9 @@ class CrawKnowledgeService {
2325
简书专题URLs.forEach {
2426
for (page in 1..100) {
2527
try {
26-
crawJianShuArticles(page, it.url)
28+
launch(CommonPool) {
29+
crawJianShuArticles(page, it.url)
30+
}
2731
} catch (e: Exception) {
2832

2933
}
@@ -36,7 +40,9 @@ class CrawKnowledgeService {
3640
fun doCrawSegmentFaultKnowledge() {
3741
for (page in 1..803) {
3842
try {
39-
crawSegmentFault(page)
43+
launch(CommonPool) {
44+
crawSegmentFault(page)
45+
}
4046
} catch (e: Exception) {
4147

4248
}
@@ -47,7 +53,9 @@ class CrawKnowledgeService {
4753
fun doCrawOSChinaKnowledge() {
4854
for (page in 1..560) {
4955
try {
50-
crawOSChina(page)
56+
launch(CommonPool) {
57+
crawOSChina(page)
58+
}
5159
} catch (e: Exception) {
5260

5361
}

src/main/kotlin/com/light/saber/webclient/CrawlerWebClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object CrawlerWebClient {
2323
}
2424

2525
fun getPageHtmlText(url: String): String? {
26-
webClient = instanceWebClient(7000)
26+
webClient = instanceWebClient(3000)
2727
try {
2828
return webClient?.getPage<HtmlPage>(url)?.asXml()
2929
} catch (e: Exception) {

src/main/resources/templates/common/foot.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
</div>
22
<div class="layui-footer" style="text-align: center">
33
<!-- 底部固定区域 -->
4-
微技 GD(MircoTek GD), 最懂你的工作伴侣。 © microtek-gd.com
4+
微技 GD © microtek-gd.com
55
</div>
66
</div>
77
</body>

src/main/resources/templates/common/head.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<li class="layui-nav-item"><a href="">机器人管理</a></li>
6464
<li class="layui-nav-item"><a href="">发布服务</a></li>
6565
</ul>
66+
6667
</div>
6768
</div>
6869

0 commit comments

Comments
 (0)