运行下载和解析脚本时拒绝CloudFlare访问

时间:2015-11-18 10:49:22

标签: python html cloudflare ddos

我正在处理一个法律问题,并建立了一个脚本,因此我没有必要手动搜索网站。

脚本:

import sys, urllib

servno = 2000
servernomax = 2676
alldat = ""

while True:
    newdat = ""
    url = "http://coc-servers.com/servers/"+str(servno)
    wp = str(urllib.urlopen(url).read())
    print wp
    ind1 = wp.find('"IP: "')
    if ind1 != -1:
        ind1 += 7
        ind2 = wp.find('http',ind1)
        ind3 = wp.find('"',ind2)
        IPurl = wp[ind2:ind3]
        newdat += IPurl
    ind4 = wp.find("<th>Webiste</th>")
    if ind4 != -1:
        ind4 +=22
        ind5 = wp.find('http',ind4)
        ind6 = wp.find('"',ind5)
        Website = wp[ind5:ind6]
        newdat += ", "
        newdat += Website
    alldat += newdat
    servno +=1
    #print ind1, ind4
    if servno > 2676: break

print alldat
sys.exit()

没有错误,但有些值需要调整。

输出?

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Access denied | coc-servers.com used CloudFlare to restrict access</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]-->
<style type="text/css">body{margin:0;padding:0}</style>
<!--[if lte IE 9]><script type="text/javascript" src="/cdn-cgi/scripts/jquery.min.js"></script><![endif]-->
<!--[if gte IE 10]><!--><script type="text/javascript" src="/cdn-cgi/scripts/zepto.min.js"></script><!--<![endif]-->
<script type="text/javascript" src="/cdn-cgi/scripts/cf.common.js"></script>

</head>
<body>
    <div id="cf-wrapper">
        <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
        <div id="cf-error-details" class="cf-error-details-wrapper">
            <div class="cf-wrapper cf-header cf-error-overview">
                <h1>
                    <span class="cf-error-type" data-translate="error">Error</span>
                    <span class="cf-error-code">1010</span>
                    <small class="heading-ray-id">Ray ID: 24730841e07509a6 &bull; 2015-11-18 10:36:04 UTC</small>
                </h1>
                <h2 class="cf-subheadline" data-translate="error_desc">Access denied</h2>
            </div><!-- /.header -->

            <section></section><!-- spacer -->

            <div class="cf-section cf-wrapper">
                <div class="cf-columns two">
                    <div class="cf-column">
                        <h2 data-translate="what_happened">What happened?</h2>
                        <p>The owner of this website (coc-servers.com) has banned your access based on your browser's signature (24730841e07509a6-ua48).</p>
                    </div>


                </div>
            </div><!-- /.section -->

            <div class="cf-error-footer cf-wrapper">
    <p>
        <span class="cf-footer-item">CloudFlare Ray ID: <strong>24730841e07509a6</strong></span>
        <span class="cf-footer-separator">&bull;</span>
        <span class="cf-footer-item"><span data-translate="your_ip">Your IP</span>: 64.18.227.167</span>
        <span class="cf-footer-separator">&bull;</span>
        <span class="cf-footer-item"><span data-translate="performance_security_by">Performance &amp; security by</span> <a data-orig-proto="https" data-orig-ref="www.cloudflare.com/5xx-error-landing?utm_source=error_footer" id="brand_link" target="_blank">CloudFlare</a></span>

    </p>
</div><!-- /.error-footer -->


        </div><!-- /#cf-error-details -->
    </div><!-- /#cf-wrapper -->

    <script type="text/javascript">
    window._cf_translation = {};


</script>

</body>
</html>
好吧,好吧,等等......什么?拒绝访问?我被禁止了?基于我的浏览器?

我该如何解决这个问题?我知道CloudFlare是为了防止DDoS而构建的,但是,这根本不是DDoS。

我会尝试实现延迟,但是,第一个到最后一个响应是相同的消息。

实施多个浏览器代理并延迟修复它,还是我完成了?

1 个答案:

答案 0 :(得分:1)

http://wolfprojects.altervista.org/articles/change-urllib-user-agent/上的文档之后,我成功地运行了脚本而没有错误,或者cloudflare禁止我。

新脚本是:

data-urll="<?php
     if($whim_available >= 1)
   {
       if($details['reward_type']=="play_to_win")
         {

    echo '$.auctions.bid(' .$details['id']  . ', $(this), event);';
         }
        if($details['reward_type']=="whim_it_now")
         {

        echo '$.auctions.claim(' . $details['id']  . ', $(this), event);';
          }

          }
 else
{
    echo "$.auctions.alert('You do not have sufficient Loots');";
      }
    ?>"

谁知道import sys from urllib import FancyURLopener servno = 2224 #2000 servernomax = 2676 alldat = "" class MyOpener(FancyURLopener): version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11' mopen = MyOpener() while True: newdat = "" url = "http://coc-servers.com/servers/"+str(servno) wp = str(mopen.open(url).read())#str(urlopen(url).read()) #print wp ind1 = wp.find('IP: ') if ind1 != -1: ind1 += 7 ind2 = wp.find('http',ind1) ind3 = wp.find('"',ind2) IPurl = wp[ind2:ind3] newdat += IPurl ind4 = wp.find("<th>Website</th>") if ind4 != -1: ind4 +=22 ind5 = wp.find('http',ind4) ind6 = wp.find('"',ind5) Website = wp[ind5:ind6] newdat += ", " newdat += Website newdat += ";;; " alldat += newdat servno +=1 #print ind1, ind4 if servno > 2676: break print alldat sys.exit() 会如此有用? :)