模板渲染 引入ejs 两个接口 一个接口是后端代理(/api/jobs) 拿数据 一个是前端要渲染的页面(/component/com-jobs.html)
后端:
var express = require(‘express’);
var router = express.Router();
var https=require(“https”)
/* GET home page. */
router.get("/api/jobs", function(req, res) {
let page=req.query.page-1
https.get(https://fe-api.zhaopin.com/c/i/sou?start=${page*90}&pageSize=90&cityId=530&workExperience=-1&education=-1&companyType=-1&employmentType=-1&jobWelfareTag=-1&kw=%E5%89%8D%E7%AB%AF&kt=3&_v=0.25978178&x-zp-page-request-id=25dd83ba223a4c37817d8f21fb4b100b-1571732299565-497131&x-zp-client-id=82795184-186a-4b78-b6aa-32510d48ec2d
,function(response){
let data=Buffer.alloc()
response.on("data",function(d){
data+=d
})
response.on("end",function(){
res.json(Json.parse(data))
})
})
})
module.exports = router;