准备模块
使用的axios,cheerio,mysql模块都是第三方模块,需要提前下载
let mysql = require('mysql'),
axios = require('axios'),
cheerio = require('cheerio'),
path = require('path'),
fs = require('fs');
连接数据库
let options = {
host: 'localhost',
port: '3306',
user: 'root',
password: '123456',
database: 'imgs'
};
//创建连接对象
let con = mysql.createConnection(options),
count = 200,//爬取总的页数
page = 1,