curl: can't fetch rss from website because of CloudFlare

前端 未结 3 1156
无人及你
无人及你 2020-12-17 02:56

I\'m notable to connect this site http://www.youm7.com/newtkarirrss.asp using curl on the server

But i can access it from localhost with out any pro

3条回答
  •  萌比男神i
    2020-12-17 03:34

    You can pass cloudflare protection with PhantomJS http://phantomjs.org/ which can execute the cloudflare JS outside a browser with following little script "delay.js":

    "use strict";
    var page = require('webpage').create(),
        system = require('system'),
        address, delay;
    
    if (system.args.length < 3 || system.args.length > 5) {
        console.log('Usage: delay.js URL delay');
        phantom.exit(1);
    } else {
        address = system.args[1];
        delay = system.args[2];
        page.open(address, function (status) {
            if (status !== 'success') {
                console.log('Unable to load the address!');
                phantom.exit(1);
            } else {
                window.setTimeout(function () {
                    var content = page.content;
                    console.log(content);
                    phantom.exit();
                }, delay);
            }
        });
    }
    

    run it as phantomjs delay.js http://protected.url 5000

    This will get "protected.url" and wait 5000ms for the cloudflare code to load the real page and dumps it to stdout.

提交回复
热议问题