如何使木偶戏无法被发现?

时间:2019-07-25 12:21:29

标签: node.js web-scraping chromium puppeteer

我正在尝试使用伪造者抓取超市网站。我可以使用chrome web scraper插件进行抓取,尽管我希望能够以编程方式进行抓取。我得到的只是一个空白屏幕,页面上没有内容加载。

我已经尝试了网络上的所有提示和技巧,以使木偶戏无法被发现并且没有任何效果。如下所示,尽管似乎没有任何作用,但我设置了许多类似于普通浏览器会话的选项。有人有什么技巧可以帮助我抓取该网站吗?

这是我尝试过的代码:

const puppeteer = require('puppeteer');

(async function main() {
    try {

        const args = [
            '--no-sandbox',
            '--disable-setuid-sandbox',
            '--disable-infobars',
            '--window-position=0,0',
            '--ignore-certifcate-errors',
            '--ignore-certifcate-errors-spki-list',
            '--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"'
        ];

        const options = {
            args,
            headless: false,
            ignoreHTTPSErrors: true,
            userDataDir: './tmp',
            dumpio: true,
            devtools: true
        };

        //launch the browser
        const browser = await puppeteer.launch(options);

        //open new page
        const page = await browser.newPage();

        //set the browser viewport
        await page.setViewport({
            width: 1920,
            height: 1080,
        });

        //set the language to english
        await page.setExtraHTTPHeaders({
            'Accept-Language': 'en'
        });
        //set the URL in a variable
        const url = 'https://shop.coles.com.au/a/a-national/product/vanish-napisan-gold-pro-oxiaction';
        //Go to the page
        await page.goto(url, { "waitUntil": "networkidle2" });
        //get the title
        const productTitle = await page.$eval('span.product-name', el => el.innerText.trim());
        //log the title in the console
        console.log(productTitle);


    } catch (e) {
        console.log('our error', e);
    }

})();

我还应该尝试什么?

1 个答案:

答案 0 :(得分:1)

它正在发布到指纹脚本。

所以您需要以某种方式拦截它并对其进行更改。

charles