我正在试图抓一个网站:http://www.vehiculo-robado.com但是还是给我这个:
error: null
statusCode: 200
body: <html style="height:100%"><head><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><meta name="format-detection" content="telephone=no"><meta name="viewport" content="initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></head><body style="margin:0px;height:100%"><iframe src="/_Incapsula_Resource?CWUDNSAI=9&xinfo=6-31980899-0%202NNN%20RT%281508782951589%204%29%20q%280%20-1%20-1%20-1%29%20r%280%20-1%29%20B12%284%2c315%2c0%29&incident_id=874000030218433631-157072954141311030&edet=12&cinfo=04000000" frameborder=0 width="100%" height="100%" marginheight="0px" marginwidth="0px">Request unsuccessful. Incapsula incident ID: 874000030218433631-157072954141311030</iframe></body></html>
网络有HTML ......
这是我用来刮网的中间件:
const request = require('request');
function webScraped(req,res,next){
const url = `http://www.vehiculo-robado.com`
req.webParsed = function webToScrape (callback){
request(url, function(error, response, body){
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body =========>', body)
return callback(false, body);
})
}
next()
}
module.exports = webScraped
我尝试过像谷歌这样的其他网站,它让我的回复很好。 我不知道我做错了什么。
答案 0 :(得分:0)
该网站(vehiculo-robado)正在使用名为SiteLock的抓取保护服务。这就是为什么它拒绝您的请求并向您发送基本为空的html的原因。这是我得到的答复:
<html style="height:100%">
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body style="margin:0px;height:100%"><iframe
src="/_Incapsula_Resource?SWUDNSAI=9&xinfo=3-7455753-0%200NNN%20RT%281550759526831%201%29%20q%280%20-1%20-1%20-1%29%20r%280%20-1%29%20B12%284%2c316%2c0%29%20U10000&incident_id=511001260010653929-37058068785072099&edet=12&cinfo=04000000"
frameborder=0 width="100%" height="100%" marginheight="0px" marginwidth="0px">Request unsuccessful. Incapsula
incident ID:
511001260010653929-37058068785072099</iframe></body>
</html>
可以通过将您的请求调整为普通用户的浏览器请求来绕过它。