Compare commits

...

12 Commits

Author SHA1 Message Date
xxy
5d70e44021 Update README.md 2022-07-15 00:49:35 +08:00
607deaa82f build: v3.6.2 发布 2022-07-15 00:44:10 +08:00
b997367f1a Merge github.com:201206030/novel-plus into develop_xxy 2022-07-15 00:32:30 +08:00
3d3cbc22b6 feat: 增加 HTTP 代理配置,助力爬虫采集 2022-07-14 23:41:47 +08:00
ba272bd89a feat: 增加 HTTP 代理配置,助力爬虫采集 2022-07-14 22:14:11 +08:00
xxy
7d1b024c4d Update README.md 2022-07-14 17:48:10 +08:00
xxy
e732c0fdee Update README.md 2022-07-14 17:47:29 +08:00
xxy
78de1de846 Update README.md 2022-07-14 17:45:36 +08:00
0b728b9fe5 docs: 修改 sql 文件说明 2022-07-14 14:19:05 +08:00
ec3428c358 docs: 增加 sql 说明 2022-07-14 14:09:43 +08:00
xxy
3c322a9d0e Update README.md 2022-07-14 13:44:54 +08:00
xxy
cdceb3818d Update README.md 2022-07-14 13:40:23 +08:00
14 changed files with 119 additions and 51 deletions

View File

@ -1,9 +1,12 @@
[![index]( https://s1.ax1x.com/2022/05/17/O5tgbR.png )]( https://curl.qcloud.com/kgMaOjoq ) [![index]( https://youdoc.github.io/img/kuaidl4.png )]( https://www.kuaidaili.com/?ref=mdpz65syhqup )
[![Github stars](https://img.shields.io/github/stars/201206030/novel-plus?logo=github)](https://github.com/201206030/novel-plus) <p align="center">
[![Github forks](https://img.shields.io/github/forks/201206030/novel-plus?logo=github)](https://github.com/201206030/novel-plus) <a href='https://github.com/201206030/novel-plus'><img alt="Github stars" src="https://img.shields.io/github/stars/201206030/novel-plus?logo=github"></a>
[![Gitee star](https://gitee.com/novel_dev_team/novel-plus/badge/star.svg?theme=gitee)](https://gitee.com/novel_dev_team/novel-plus) <a href='https://github.com/201206030/novel-plus'><img alt="Github forks" src="https://img.shields.io/github/forks/201206030/novel-plus?logo=github"></a>
[![Gitee fork](https://gitee.com/novel_dev_team/novel-plus/badge/fork.svg?theme=gitee)](https://gitee.com/novel_dev_team/novel-plus) <a href='https://gitee.com/novel_dev_team/novel-plus'><img alt="Gitee stars" src="https://gitee.com/novel_dev_team/novel-plus/badge/star.svg?theme=gitee"></a>
<a href='https://gitee.com/novel_dev_team/novel-plus'><img alt="Gitee forks" src="https://gitee.com/novel_dev_team/novel-plus/badge/fork.svg?theme=gitee"></a>
<a href="https://github.com/201206030/novel-plus"><img src="https://visitor-badge.glitch.me/badge?page_id=201206030.novel-plus" alt="visitors"></a>
</p>
#### 官网 #### 官网
@ -11,7 +14,7 @@ https://201206030.github.io
#### 学习版 #### 学习版
[基于 Spring Boot 3 + Vue 3 开发的前后端分离学习型小说项目](https://github.com/201206030/novel) [基于 Spring Boot 3 + Vue 3 开发的前后端分离学习型小说项目](https://github.com/201206030/novel)
#### 微服务版 #### 微服务版
@ -211,12 +214,13 @@ novel-plus -- 父工程
2. 使用`unzip novel-crawl.zip`命令解压 novel-crawl.zip 2. 使用`unzip novel-crawl.zip`命令解压 novel-crawl.zip
3. 修改 `config/application-common-prod.yml` 文件中的数据库配置 3. 修改 `config/application-common-prod.yml` 文件中的数据库配置
4. 修改 `config/application-common-prod.yml` 文件中的管理员账号密码 4. 修改 `config/application-common-prod.yml` 文件中的管理员账号密码
5. novel-crawl 目录下使用`bin/novel-crawl.sh start`命令启动爬虫程序 5. 根据需要[设置爬虫的代理IP](https://github.com/201206030/novel-plus/wiki/%E7%88%AC%E8%99%AB%E7%A8%8B%E5%BA%8F-HTTP-%E4%BB%A3%E7%90%86%E8%AE%BE%E7%BD%AE)
6. 打开浏览器默认`8083`端口访问 6. novel-crawl 目录下使用`bin/novel-crawl.sh start`命令启动爬虫程序
7. 选择已有或新增爬虫源支持自定义爬虫规则点击`开启`按钮开始采集小说数据 7. 打开浏览器默认`8083`端口访问
8. novel-crawl 目录下使用`bin/novel-crawl.sh stop`命令停止爬虫程序 8. 选择已有或新增爬虫源支持自定义爬虫规则点击`开启`按钮开始采集小说数据
9. novel-crawl 目录下使用`bin/novel-crawl.sh restart`命令重启爬虫程序 9. novel-crawl 目录下使用`bin/novel-crawl.sh stop`命令停止爬虫程序
10. novel-crawl 目录下使用`bin/novel-crawl.sh status`命令查看爬虫程序的运行状态 10. novel-crawl 目录下使用`bin/novel-crawl.sh restart`命令重启爬虫程序
11. novel-crawl 目录下使用`bin/novel-crawl.sh status`命令查看爬虫程序的运行状态
- 前台安装 - 前台安装
@ -255,7 +259,7 @@ Gitee 仓库地址: https://gitee.com/novel_dev_team/novel-plus
#### 微信交流群 #### 微信交流群
微信群二维码会过期所以每周在公众号更新一次请关注公众号**IT进阶**回复关键词**微信群**获取 微信群二维码会过期所以每周在公众号更新一次请关注公众号**xxyopen**回复关键词**微信群**获取
问问题的三要素 问问题的三要素
@ -282,7 +286,3 @@ Gitee 仓库地址: https://gitee.com/novel_dev_team/novel-plus
#### 免责声明 #### 免责声明
本项目提供的爬虫工具仅用于采集项目初期的测试数据请勿用于商业盈利 用户使用本系统从事任何违法违规的事情一切后果由用户自行承担作者不承担任何责任 本项目提供的爬虫工具仅用于采集项目初期的测试数据请勿用于商业盈利 用户使用本系统从事任何违法违规的事情一切后果由用户自行承担作者不承担任何责任
#### 备注
精品小说屋所有相关项目均已在开源中国公开感兴趣的可进入[开源中国](https://www.oschina.net/p/fiction_house)按关键字`精品小说屋`搜索。

3
doc/sql/readme.md Normal file
View File

@ -0,0 +1,3 @@
1. novel_plus.sql 为全量 sql 文件yyyyMMdd.sql 为增量 sql 文件
2. 第一次安装只需要执行 novel_plus.sql 文件即可
3. 后续版本升级需要根据上次代码版本的时间执行该日期之后的增量 sql 文件简单来说就是 sql 文件夹中相较于上次多出来的 sql 文件

View File

@ -1,3 +0,0 @@
novel_plus.sqlΪȫ<CEAA><C8AB>sql<71>ļ<EFBFBD><C4BC><EFBFBD>yyyyMMdd.sqlΪ<6C><CEAA><EFBFBD><EFBFBD>sql<71>ļ<EFBFBD><C4BC><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֻ<EFBFBD><EFBFBD>Ҫִ<EFBFBD><EFBFBD>novel_plus.sql<71>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ɡ<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD>󣬸<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴδ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬ִ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sql<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>

View File

@ -5,7 +5,7 @@
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<artifactId>novel-admin</artifactId> <artifactId>novel-admin</artifactId>
<version>3.6.1</version> <version>3.6.2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>novel-admin</name> <name>novel-admin</name>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<version>3.6.1</version> <version>3.6.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -142,7 +142,6 @@
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -0,0 +1,22 @@
package com.java2nb.novel.core.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @author xiongxiaoyang
* @date 2022/7/14
*/
@Data
@Component
@ConfigurationProperties(prefix = "http.proxy")
public class HttpProxyProperties {
private Boolean enabled;
private String ip;
private Integer port;
}

View File

@ -1,6 +1,8 @@
package com.java2nb.novel.core.utils; package com.java2nb.novel.core.utils;
import com.java2nb.novel.core.config.HttpProxyProperties;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.apache.http.HttpHost;
import org.apache.http.config.Registry; import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder; import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.ConnectionSocketFactory;
@ -8,37 +10,46 @@ import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.List; import java.util.List;
import java.util.Objects;
@Component
public class RestTemplateUtil { public class RestTemplateUtil {
private static HttpProxyProperties httpProxyProperties;
RestTemplateUtil(HttpProxyProperties properties) {
httpProxyProperties = properties;
}
@SneakyThrows @SneakyThrows
public static RestTemplate getInstance(String charset) { public static RestTemplate getInstance(String charset) {
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
//忽略证书 //忽略证书
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom() SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
.loadTrustMaterial(null, acceptingTrustStrategy) .loadTrustMaterial(null, acceptingTrustStrategy)
.build(); .build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext); SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", csf) .register("https", csf)
.build(); .build();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
//连接池的最大连接数0代表不限如果取0需要考虑连接泄露导致系统崩溃的后果 //连接池的最大连接数0代表不限如果取0需要考虑连接泄露导致系统崩溃的后果
@ -46,22 +57,26 @@ public class RestTemplateUtil {
//每个路由的最大连接数,如果只调用一个地址,可以将其设置为最大连接数 //每个路由的最大连接数,如果只调用一个地址,可以将其设置为最大连接数
connectionManager.setDefaultMaxPerRoute(300); connectionManager.setDefaultMaxPerRoute(300);
CloseableHttpClient httpClient = HttpClients.custom() HttpClientBuilder clientBuilder = HttpClients.custom();
.setConnectionManager(connectionManager) if (Objects.nonNull(httpProxyProperties) && Boolean.TRUE.equals(httpProxyProperties.getEnabled())) {
.build(); HttpHost proxy = new HttpHost(httpProxyProperties.getIp(), httpProxyProperties.getPort());
clientBuilder.setProxy(proxy);
}
CloseableHttpClient httpClient = clientBuilder.setConnectionManager(connectionManager)
.build();
HttpComponentsClientHttpRequestFactory requestFactory = HttpComponentsClientHttpRequestFactory requestFactory =
new HttpComponentsClientHttpRequestFactory(); new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient); requestFactory.setHttpClient(httpClient);
requestFactory.setConnectionRequestTimeout(3000); requestFactory.setConnectionRequestTimeout(3000);
requestFactory.setConnectTimeout(3000); requestFactory.setConnectTimeout(3000);
requestFactory.setReadTimeout(30000); requestFactory.setReadTimeout(30000);
RestTemplate restTemplate = new RestTemplate(requestFactory); RestTemplate restTemplate = new RestTemplate(requestFactory);
List<HttpMessageConverter<?>> list = restTemplate.getMessageConverters(); List<HttpMessageConverter<?>> list = restTemplate.getMessageConverters();
for (HttpMessageConverter<?> httpMessageConverter : list) { for (HttpMessageConverter<?> httpMessageConverter : list) {
if(httpMessageConverter instanceof StringHttpMessageConverter) { if (httpMessageConverter instanceof StringHttpMessageConverter) {
((StringHttpMessageConverter) httpMessageConverter).setDefaultCharset(Charset.forName(charset)); ((StringHttpMessageConverter) httpMessageConverter).setDefaultCharset(Charset.forName(charset));
break; break;
} }

View File

@ -1,6 +1,6 @@
spring: spring:
profiles: profiles:
include: [common] include: [ common ]
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
#Redis服务器IP #Redis服务器IP
@ -54,24 +54,30 @@ sharding:
props: props:
sql.show: true sql.show: true
tables: tables:
book_content: #book_content表 book_content: #book_content表
key-generator-column-name: id #主键 key-generator-column-name: id #主键
actual-data-nodes: ds${0}.book_content${0..9} #数据节点 actual-data-nodes: ds${0}.book_content${0..9} #数据节点
# database-strategy: #分库策略 # database-strategy: #分库策略
# inline: # inline:
# sharding-column: book_id # sharding-column: book_id
# algorithm-expression: ds${book_id % 10} # algorithm-expression: ds${book_id % 10}
table-strategy: #分表策略 table-strategy: #分表策略
inline: inline:
shardingColumn: index_id shardingColumn: index_id
algorithm-expression: book_content${index_id % 10} algorithm-expression: book_content${index_id % 10}
content: content:
save: save:
storage: db #存储介质db数据库filetxt文本 storage: db #存储介质db数据库filetxt文本
path: /Users/xiongxiaoyang/books #txt小说文本保存路径 path: /Users/xiongxiaoyang/books #txt小说文本保存路径
# HTTP 代理配置
http:
proxy:
# 是否开启 HTTP 代理true-开启false-不开启
enabled: false
# 代理 IP
ip: u493.kdltps.com
# 代理端口号
port: 15818

View File

@ -1,6 +1,6 @@
spring: spring:
profiles: profiles:
include: [common] include: [ common ]
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
#Redis服务器IP #Redis服务器IP
@ -54,14 +54,14 @@ sharding:
props: props:
sql.show: true sql.show: true
tables: tables:
book_content: #book_content表 book_content: #book_content表
key-generator-column-name: id #主键 key-generator-column-name: id #主键
actual-data-nodes: ds${0}.book_content${0..9} #数据节点 actual-data-nodes: ds${0}.book_content${0..9} #数据节点
# database-strategy: #分库策略 # database-strategy: #分库策略
# inline: # inline:
# sharding-column: book_id # sharding-column: book_id
# algorithm-expression: ds${book_id % 10} # algorithm-expression: ds${book_id % 10}
table-strategy: #分表策略 table-strategy: #分表策略
inline: inline:
shardingColumn: index_id shardingColumn: index_id
algorithm-expression: book_content${index_id % 10} algorithm-expression: book_content${index_id % 10}
@ -79,7 +79,15 @@ content:
storage: db #存储介质db数据库filetxt文本 storage: db #存储介质db数据库filetxt文本
path: /Users/xiongxiaoyang/books #txt小说文本保存路径 path: /Users/xiongxiaoyang/books #txt小说文本保存路径
# HTTP 代理配置
http:
proxy:
# 是否开启 HTTP 代理true-开启false-不开启
enabled: false
# 代理 IP
ip: 40.83.102.86
# 代理端口号
port: 80

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<version>3.6.1</version> <version>3.6.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -36,4 +36,14 @@ crawl:
content: content:
save: save:
storage: db #存储介质db数据库filetxt文本 storage: db #存储介质db数据库filetxt文本
path: /Users/xiongxiaoyang/books #txt小说文本保存路径 path: /Users/xiongxiaoyang/books #txt小说文本保存路径
# HTTP 代理配置
http:
proxy:
# 是否开启 HTTP 代理true-开启false-不开启
enabled: false
# 代理 IP
ip: u493.kdltps.com
# 代理端口号
port: 15818

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<version>3.6.1</version> <version>3.6.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -41,5 +41,13 @@ content:
# HTTP 代理配置
http:
proxy:
# 是否开启 HTTP 代理true-开启false-不开启
enabled: false
# 代理 IP
ip: u493.kdltps.com
# 代理端口号
port: 15818

View File

@ -5,7 +5,7 @@
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<version>3.6.1</version> <version>3.6.2</version>
<modules> <modules>
<module>novel-common</module> <module>novel-common</module>
<module>novel-front</module> <module>novel-front</module>