-
Notifications
You must be signed in to change notification settings - Fork 97
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
0 parents
commit 619caa0
Showing
40 changed files
with
6,906 additions
and
0 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,67 @@ | ||
var express = require('express'); | ||
var path = require('path'); | ||
var favicon = require('serve-favicon'); | ||
var logger = require('morgan'); | ||
var cookieParser = require('cookie-parser'); | ||
var bodyParser = require('body-parser'); | ||
|
||
var routes = require('./routes/index'); | ||
var users = require('./routes/users'); | ||
var homeapi =require("./routes/spider/home"); | ||
var coupleapi = require("./routes/spider/couplelist"); | ||
var categoryapi = require("./routes/spider/categorylist"); | ||
var searchapi = require("./routes/spider/search"); | ||
var app = express(); | ||
|
||
// view engine setup | ||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'ejs'); | ||
|
||
// uncomment after placing your favicon in /public | ||
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); | ||
app.use(logger('dev')); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
app.use(cookieParser()); | ||
app.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
app.use('/', routes); | ||
app.use('/users', users); | ||
app.use("/home",homeapi); | ||
app.use("/couplelist",coupleapi); | ||
app.use("/categorylist",categoryapi); | ||
app.use("/search",searchapi); | ||
|
||
// catch 404 and forward to error handler | ||
app.use(function(req, res, next) { | ||
var err = new Error('Not Found'); | ||
err.status = 404; | ||
next(err); | ||
}); | ||
|
||
// error handlers | ||
|
||
// development error handler | ||
// will print stacktrace | ||
if (app.get('env') === 'development') { | ||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.render('error', { | ||
message: err.message, | ||
error: err | ||
}); | ||
}); | ||
} | ||
|
||
// production error handler | ||
// no stacktraces leaked to user | ||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.render('error', { | ||
message: err.message, | ||
error: {} | ||
}); | ||
}); | ||
|
||
|
||
module.exports = app; |
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,90 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var app = require('../app'); | ||
var debug = require('debug')('backend:server'); | ||
var http = require('http'); | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
|
||
var port = normalizePort(process.env.PORT || '3000'); | ||
app.set('port', port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
var server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port); | ||
server.on('error', onError); | ||
server.on('listening', onListening); | ||
|
||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
var port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error; | ||
} | ||
|
||
var bind = typeof port === 'string' | ||
? 'Pipe ' + port | ||
: 'Port ' + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(bind + ' requires elevated privileges'); | ||
process.exit(1); | ||
break; | ||
case 'EADDRINUSE': | ||
console.error(bind + ' is already in use'); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
var addr = server.address(); | ||
var bind = typeof addr === 'string' | ||
? 'pipe ' + addr | ||
: 'port ' + addr.port; | ||
debug('Listening on ' + bind); | ||
} |
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,20 @@ | ||
{ | ||
"name": "backend", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "node-dev ./bin/www" | ||
}, | ||
"dependencies": { | ||
"body-parser": "~1.15.1", | ||
"cookie-parser": "~1.4.3", | ||
"debug": "~2.2.0", | ||
"ejs": "~2.4.1", | ||
"express": "~4.13.4", | ||
"morgan": "~1.7.0", | ||
"serve-favicon": "~2.3.0" | ||
}, | ||
"devDependencies": { | ||
"request": "^2.81.0" | ||
} | ||
} |
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,8 @@ | ||
body { | ||
padding: 50px; | ||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; | ||
} | ||
|
||
a { | ||
color: #00B7FF; | ||
} |
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,9 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
res.render('index', { title: 'Express' }); | ||
}); | ||
|
||
module.exports = router; |
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,11 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var spider = require("./spider"); | ||
|
||
router.get("/",function(req,res,next){ | ||
spider(`/category/categorylist?device=iphone&channel=h5&swidth=375&sheight=667&zoneId=1479&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F%23category%3Fchannel_id%3Dh5`,function(data){ | ||
res.send(data); | ||
}); | ||
}) | ||
|
||
module.exports =router; |
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,18 @@ | ||
var express =require("express"); | ||
var router = express.Router(); | ||
var spider = require("./spider"); | ||
router.get("/index",function(req,res,next){ | ||
|
||
spider("/common/pinindex?device=iphone&channel=h5&swidth=375&sheight=667&zoneId=857&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F%23couple_list%3FshowFooter%3D1%26channel_id%3Dh5",function(data){ | ||
res.send(data); | ||
}) | ||
}) | ||
|
||
router.get("/product",function(req,res,next){ | ||
spider(`/product/coupleskulist?device=iphone&channel=h5&swidth=375&sheight=667&zoneId=857&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F%23couple_list%3FshowFooter%3D1%26channel_id%3Dh5&needPagination=1&pageNum=${req.query.num}&pageLimit=20`,function(data){ | ||
res.send(data); | ||
}) | ||
}) | ||
|
||
module.exports = router; | ||
|
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,18 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var spider = require("./spider"); | ||
|
||
router.get("/index",function(req,res,next){ | ||
spider(`/common/index?device=iphone&channel=h5&swidth=375&sheight=667&zoneId=1479&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F`,function(data){ | ||
res.send(data); | ||
}); | ||
}) | ||
|
||
|
||
router.get("/recommend",function(req,res,next){ | ||
spider(`/product/recommendproducts?device=iphone&channel=h5&swidth=375&sheight=667&zoneId=1479&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F&needPagination=1&pageNum=${req.query.num}&pageLimit=20`,function(data){ | ||
res.send(data); | ||
}); | ||
}) | ||
|
||
module.exports =router; |
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,25 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var spider = require("./spider"); | ||
|
||
router.get("/",function(req,res,next){ | ||
spider(`/common/hotsearchsug?device=iphone&channel=h5&swidth=375&sheight=667&zoneId=1479&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F%23search%3Fchannel_id%3Dh5`,function(data){ | ||
res.send(data); | ||
}); | ||
}) | ||
|
||
router.get("/list",function(req,res,next){ | ||
|
||
spider(`/product/itemssearch?device=iphone&channel=h5&swidth=375&sheight=667&zoneId=2459&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F%23list%3Fsearchtag%3D${encodeURIComponent(req.query.text)}%26backLevel%3D-2%26channel_id%3Dh5&searchTag=${encodeURIComponent(req.query.text)}&q=${encodeURIComponent(req.query.text)}&needPagination=1&pageNum=${req.query.num}&pageLimit=20`,function(data){ | ||
res.send(data); | ||
}) | ||
}) | ||
|
||
router.get("/category",function(req,res,next){ | ||
|
||
spider(`/product/itemssearch?device=pc&channel=h5&swidth=1440&sheight=900&zoneId=1479&v=2.3.0&terminal=wap&page=https%3A%2F%2Fm.haoshiqi.net%2F%23list%3Fcategoryname%3D${encodeURIComponent(req.query.text)}%26categoryid%3D${req.query.id}%26channel_id%3Dh5&categoryId=${req.query.id}&category=${encodeURIComponent(req.query.text)}&needPagination=1&pageNum=${req.query.num}&pageLimit=20`,function(data){ | ||
res.send(data); | ||
}) | ||
}) | ||
|
||
module.exports =router; |
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,23 @@ | ||
/** | ||
* Created by Kerwin on 2017/4/17. | ||
*/ | ||
var request = require("request"); | ||
function spider(path,callback){ | ||
var options = { | ||
url: 'http://m.api.haoshiqi.net'+path, | ||
headers:{ | ||
"Accept":"application/json", | ||
"Accept-Encoding":"gzip, deflate, sdch, br", | ||
"Accept-Language":"zh-CN,zh;q=0.8", | ||
"Referer":"https://m.haoshiqi.net/", | ||
"User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1" | ||
} | ||
}; | ||
|
||
request(options, function(error, response, body){ | ||
callback && callback(body); | ||
}); | ||
|
||
} | ||
|
||
module.exports = spider; |
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,9 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
/* GET users listing. */ | ||
router.get('/', function(req, res, next) { | ||
res.send('respond with a resource'); | ||
}); | ||
|
||
module.exports = router; |
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,3 @@ | ||
<h1><%= message %></h1> | ||
<h2><%= error.status %></h2> | ||
<pre><%= error.stack %></pre> |
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,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title><%= title %></title> | ||
<link rel='stylesheet' href='/stylesheets/style.css' /> | ||
</head> | ||
<body> | ||
<h1><%= title %></h1> | ||
<p>Welcome to <%= title %></p> | ||
</body> | ||
</html> |
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,7 @@ | ||
{ | ||
"presets": [ | ||
["latest", { | ||
"es2015": { "modules": false } | ||
}] | ||
] | ||
} |
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,18 @@ | ||
# haoshiqi | ||
|
||
> A Vue.js project | ||
## Build Setup | ||
|
||
``` bash | ||
# install dependencies | ||
npm install | ||
|
||
# serve with hot reload at localhost:8080 | ||
npm run dev | ||
|
||
# build for production with minification | ||
npm run build | ||
``` | ||
|
||
For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader). |
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,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>haoshiqi</title> | ||
|
||
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/> | ||
|
||
<style> | ||
*{ | ||
margin:0px; | ||
padding:0px; | ||
box-sizing:border-box; | ||
} | ||
|
||
li{ | ||
list-style: none; | ||
box-sizing:border-box; | ||
} | ||
|
||
html,body{ | ||
width: 100%; | ||
height: 100%; | ||
background: #f8f8f8; | ||
font-size:16px; | ||
-webkit-tap-highlight-color: transparent; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script src="/dist/build.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.