在做一个爬虫,从前端的angular传过来一个路由,路由有一个参,是一个网站的url,
http://localhost:3000/newslist/http://news.neusoft.edu.cn/2015/0402/4710.shtml
newslist/ 后面的就是url参数,我希望能提取这个参数,于是我这么写:
app.get('/newslist/:url', function (req, res) {
console.log('3')
var url = req.params.path;
console.log(url);
superagent.get(url)
.end(function (err, data) {
if (err) console.log(err);
但是这样写的路由无法捕获前端传过来的值,提示:
GET http://localhost:3000/newslist/http://news.neusoft.edu.cn/2015/0402/4710.shtml 404
Cannot GET /newslist/http://news.neusoft.edu.cn/2015/0402/4710.shtml
不知正确的写法应该怎么写,望大神指点~
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
光阴似箭催人老,日月如移越少年。