简体   繁体   English

cURL - 加载具有 CloudFlare 保护的站点

[英]cURL - Load a site with CloudFlare protection

I have a site which I want to load using cURL.我有一个要使用 cURL 加载的站点。 However, the site I'm talking about is using cloudflare protection.但是,我正在谈论的站点正在使用 cloudflare 保护。 While on cURL request => it says 'checking your browser, you will be redirected in 5 seconds' and I'm getting redirected to the page that doesn't exists because as I think I didn't pass some protection test.在 cURL 请求 => 上,它说“检查您的浏览器,您将在 5 秒内被重定向”,我被重定向到不存在的页面,因为我认为我没有通过一些保护测试。

I've been looking for my answer for a long and i found only two useful links:我一直在寻找我的答案,我只找到了两个有用的链接:

Link 1 链接 1

Link 2 链接 2

But still I can't figure it out.但我还是想不通。 Any help for me?对我有什么帮助吗?

That would be CloudFlare's I'm Under Attack Mode --> http://blog.cloudflare.com/introducing-im-under-attack-mode那将是 CloudFlare 的 I'm Under Attack Mode --> http://blog.cloudflare.com/introducing-im-under-attack-mode

If you are the owner of the site you should whitelist your own IP address.如果您是该站点的所有者,则应将您自己的 IP 地址列入白名单。 If you're a visitor to the site either如果您是该网站的访问者

1.) The website owner has the feature enabled on their own website in which case it's intentional and there is no way around that as they are protecting their website or 1.) 网站所有者在他们自己的网站上启用了该功能,在这种情况下,这是有意为之,因为他们正在保护他们的网站或

2.) You are loading the site too often -- and you're triggering CloudFlare's DDOS protection. 2.) 您加载站点过于频繁——并且您触发了 CloudFlare 的 DDOS 保护。

ps Disclaimer: I work for CloudFlare. ps 免责声明:我为 CloudFlare 工作。

You can get around the in-under-attack-mode by selecting 'Copy as cUrl' in the network section under developer tools of any major browser.您可以通过在任何主要浏览器的开发人员工具下的网络部分中选择“复制为 cUrl”来绕过攻击中模式。

This copies all the required cookies so your curl can be 'authenticated'.这会复制所有必需的 cookie,以便可以“验证”您的 curl。 How long these cookies last i would assume would be up to cloudflare.我认为这些 cookie 能持续多久取决于 cloudflare。

SideNote: The curl must be run on the same IP as you were loading the site with.旁注:curl 必须在与您加载站点的 IP 相同的 IP 上运行。 Also for any real test/developing environment I would suggest selenium and/or phantomjs which are alot better and easily scriptable languages for website testing.同样对于任何真正的测试/开发环境,我建议使用selenium和/或phantomjs ,它们是用于网站测试的更好且易于编写脚本的语言。

curl 'https://ilikeurls.net/ourpage.php?do=command' \
    -H 'Host: ilikeurls.net' \
    -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0' \
    -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
    -H 'Accept-Language: en-US,en;q=0.5' \
    -H 'Referer: https://ilikeurls.net/outpage.php' \                                                    
    -H 'Cookie: all required cookies will appear here' \
    -H 'Connection: keep-alive'\
    --compressed

Though you might be better off using selenium or phantomjs to script out these tests.尽管您最好使用 selenium 或 phantomjs 来编写这些测试的脚本。

You might try adjusting your bot settings or finding a way to whitelist CURL.您可以尝试调整机器人设置或找到将 CURL 列入白名单的方法。

All my curl requests started returning 403 errors after I adjusted Cloudflare settings at Firewall > Bot.在 Firewall > Bot 中调整 Cloudflare 设置后,我的所有 curl 请求都开始返回 403 错误。 All were permitted;所有人都被允许; I set Automated to Block and Likely Automated to Challenge and it broke CURL.我将自动设置为阻止并可能自动设置为挑战,它破坏了 CURL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM