-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
changsheng
committed
Sep 17, 2020
1 parent
80135ef
commit 006982b
Showing
6 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const mysqlConfig = { | ||
host: '47.100.166.125', | ||
user: 'root', | ||
database: 'sun', | ||
password: '111!aaaA', | ||
charset: 'utf8', //应该设置编码(省略在某些情况下会有错误) | ||
//以下选项均为默认值(如果不需要变动可省略) | ||
connectTimeout: 10000, //获取连接的毫秒 | ||
waitForConnections: true, //为true时,连接排队等待可用连接。为false将立即抛出错误 | ||
connectionLimit: 20, //单次可创建最大连接数 | ||
queueLimit: 0 //连接池的最大请求数,从getConnection方法前依次排队。设置为0将没有限制 | ||
} | ||
|
||
const fetchConfig = { | ||
baseUrl: 'https://www.esrl.noaa.gov/gmd/grad/solcalc/table.php', | ||
sleepTime: 2000, //两次相隔请求之间的间隔,避免爬取服务器奔溃 | ||
} | ||
|
||
const logConfig = { | ||
level: 'info' | ||
} | ||
|
||
module.exports = { | ||
mysqlConfig: mysqlConfig, | ||
fetchConfig: fetchConfig, | ||
logConfig: logConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,49 @@ | ||
## 爬取日升日落数据 | ||
|
||
## 环境 | ||
|
||
- node v8.4.0以上 | ||
|
||
## 数据源 | ||
|
||
- ### 城市数据源 | ||
[](./sql/sun_city.sql) | ||
|
||
- ### 爬取日升日落数据源 | ||
|
||
``` | ||
https://www.esrl.noaa.gov/gmd/grad/solcalc/table.php | ||
``` | ||
|
||
### sun 表 | ||
|
||
time 日期 | ||
code 区县编码 | ||
sunrise 日升时间 | ||
solar_moon 正午时间 | ||
sunset 日落时间 | ||
|
||
### city 表 | ||
|
||
区县编码经纬度表 | ||
|
||
## 配置 | ||
|
||
[./config/config.js](./config/config.js) | ||
|
||
配置mysql库连接地址 | ||
|
||
## 运行 | ||
|
||
### 安装依赖 | ||
|
||
``` | ||
npm i | ||
``` | ||
|
||
### 运行项目 | ||
|
||
``` | ||
npm run start | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters