http请求被拒绝,没有解释

时间:2017-11-05 09:09:15

标签: javascript node.js express httprequest cheerio

使用node,express,request和cheerios构建一个抓取项目。事实证明只有一些网站确实返回了请求。像沃尔玛这样的杂货店网站甚至没有返回错误。是因为它被封锁了吗?检查了robot.text。负

const express = require("express");
const request = require("request");
const cheerio = require("cheerio");
const app = express();

const PORT = process.env.PORT || 4000;

const url = 'https://www.indeed.com/jobs?q=web+developer&l=Salt+Lake+City%2C+UT'

app.get('/scrape', (req, res)=>{
request(url, (err, res, body)=>{
  if(err){console.log("this website wont talk to you")}
      console.log(body);
});
res.send('Check your console!')
});


app.listen(PORT, ()=>{
  console.log("server is spinning on port " + PORT);
})

exports = module.exports = app;

0 个答案:

没有答案