news.properties配置文件:
#title
titleNode=/body/div[5]/div[2]/div[3]/h1/span[1]
#theYear
theYearNode=/body/div[5]/div[2]/div[1]/span[1]/em
#monthAndDay
monthAndDayNode=/body/div[5]/div[2]/div[1]/span[2]
#theTime
theTimeNode=/body/div[5]/div[2]/div[1]/span[3]
#source
sourceNode=/body/div[5]/div[2]/div[2]
#content
contentNode=//*[@id=\"detail\"]
#author
authorNode=//*[@id=\"articleEdit\"]/span[2]
#source的正则表达式
sourceRegex=来源:(.*)
#数据库连接
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://10.10.50.160:3306/learningspider?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
username=root
password=abc123456#
代码实现
/**
* @author jiangl
* @ClassName loadProperty.java
* @Description 加载news.properties配置文件
* @createTime 2021年01月11日 21:24
*/
public class loadProperty
{
//定义propertie