1

我正在尝试抓取一个网站: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

我尝试使用其他网站,如谷歌,它返回我的 html 很好。我不知道我做错了什么。

4

1 回答 1

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>

绕过它应该可以通过将您的请求塑造为普通用户的浏览器请求来实现。

于 2019-02-21T14:46:44.537 回答