<tfoot id='7eWBG'></tfoot>

    <i id='7eWBG'><tr id='7eWBG'><dt id='7eWBG'><q id='7eWBG'><span id='7eWBG'><b id='7eWBG'><form id='7eWBG'><ins id='7eWBG'></ins><ul id='7eWBG'></ul><sub id='7eWBG'></sub></form><legend id='7eWBG'></legend><bdo id='7eWBG'><pre id='7eWBG'><center id='7eWBG'></center></pre></bdo></b><th id='7eWBG'></th></span></q></dt></tr></i><div id='7eWBG'><tfoot id='7eWBG'></tfoot><dl id='7eWBG'><fieldset id='7eWBG'></fieldset></dl></div>
      • <bdo id='7eWBG'></bdo><ul id='7eWBG'></ul>

      <small id='7eWBG'></small><noframes id='7eWBG'>

    1. <legend id='7eWBG'><style id='7eWBG'><dir id='7eWBG'><q id='7eWBG'></q></dir></style></legend>

      curl:由于 CloudFlare,无法从网站获取 RSS

      curl: can#39;t fetch rss from website because of CloudFlare(curl:由于 CloudFlare,无法从网站获取 RSS)
        <legend id='ajVc1'><style id='ajVc1'><dir id='ajVc1'><q id='ajVc1'></q></dir></style></legend>

          <tbody id='ajVc1'></tbody>
          <bdo id='ajVc1'></bdo><ul id='ajVc1'></ul>
          <tfoot id='ajVc1'></tfoot>

                <small id='ajVc1'></small><noframes id='ajVc1'>

                <i id='ajVc1'><tr id='ajVc1'><dt id='ajVc1'><q id='ajVc1'><span id='ajVc1'><b id='ajVc1'><form id='ajVc1'><ins id='ajVc1'></ins><ul id='ajVc1'></ul><sub id='ajVc1'></sub></form><legend id='ajVc1'></legend><bdo id='ajVc1'><pre id='ajVc1'><center id='ajVc1'></center></pre></bdo></b><th id='ajVc1'></th></span></q></dt></tr></i><div id='ajVc1'><tfoot id='ajVc1'></tfoot><dl id='ajVc1'><fieldset id='ajVc1'></fieldset></dl></div>
                本文介绍了curl:由于 CloudFlare,无法从网站获取 RSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我注意到连接这个网站 http://www.youm7.com/newtkarirrss.asp 在服务器上使用 curl

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

                但我可以从 localhost 毫无问题地访问它

                But i can access it from localhost with out any problem

                这是测试

                http://www.tjreb.com/xml_grabber.php?feed=http://www.youm7.com/newtkarirrss.asp&stack=1

                试试 CNN RSS 提要

                Try The CNN rss feed

                http://www.tjreb.com/xml_grabber.php?feed=http://rss.cnn.com/rss/edition_meast.rss&stack=0

                如何绕过这个错误

                这是我的源代码

                <?php
                  class xml_grabber
                        {
                            private $xml_file       = '' ;
                            private $xml_link       = '' ;
                            private $xml_dom        = '' ;
                            private $xml_type       = '' ;
                            private $xml_content    = '' ;
                            private $xml_errors     = array() ;
                            public  $xml_stack      = 0  ;
                
                            public function __construct($link_file_com = '')
                                   {
                                       if(!$link_file_com)
                                            {
                                              $this->xml_errors['construct'] = 'No Xml In Construct' ;
                                              return false;
                                            }
                                       elseif(!function_exists('simplexml_load_file') || !function_exists('simplexml_load_string') || !function_exists('simplexml_import_dom'))
                                            {
                                              $this->xml_errors['functions'] = 'simple xml function not exists' ;
                                              return false;
                                            }
                                       else
                                            {
                                             $this->set_xml($link_file_com) ;
                                            }
                                      // ini_set('memory_limit', '100M');
                                   }
                
                             public function set_xml($xml)
                                   {
                                      if(isset($xml{3}))
                                        {
                                           if(file_exists($xml))
                                              {
                                                $this->xml_type = 1 ;
                                                $this->xml_file = $xml ;
                                              }
                                          elseif(filter_var($xml, FILTER_VALIDATE_URL))
                                              {
                                                $this->xml_type = 2 ;
                                                $this->xml_link = $xml ;
                                              }
                                          else
                                              {
                                                $this->xml_type = 3 ;
                                                $this->xml_dom  = $xml ;
                                              }
                                        }
                                      else
                                        {
                                          $this->xml_type = '' ;
                                        }
                                   }
                
                             public function get_xml()
                                   {
                                      if($this->xml_type == '')
                                            {
                                              return false ;
                                            }
                                      elseif($this->xml_type == 1)
                                            {
                                              return $this->xml_file ;
                                            }
                                      elseif($this->xml_type == 2)
                                            {
                                              return $this->xml_link ;
                                            }
                                      elseif($this->xml_type == 3)
                                            {
                                              return $this->xml_dom ;
                                            }
                                   }
                
                             public function set_columns($new_columns= array())
                                   {
                                      return $this->xml_columns = $new_columns ;
                                   }
                             public function get_columns()
                                   {
                                     return $this->xml_columns ;
                                   }
                
                             public function load()
                                   {
                                     if($this->xml_type == '')
                                            {
                                              $this->xml_errors['loader'] = 'Unknown XML type' ;
                                              return false;
                                            }
                                      elseif($this->xml_type == 1)
                                            {
                                              $dom = simplexml_load_file($this->xml_file,null, LIBXML_NOCDATA) ;
                                              $this->xml_content = $dom ;
                                            }
                                      elseif($this->xml_type == 2)
                                            {
                                               $con = $this->connect($this->xml_link);
                                               if($this->xml_stack == 1)
                                                    {
                                                       echo $con; die();
                                                    }       
                                               $this->xml_content = simplexml_load_string($con,null, LIBXML_NOCDATA) ;
                                            }
                                      elseif($this->xml_type == 3)
                                            {
                                              return $this->xml_dom ;
                                            }
                                   }
                
                             public function fetch($return = 'array')
                                    {
                                        if($this->xml_content != '')
                                            {
                                               $rss_feed = $this->xml_content ;
                
                                               $rss_title = (string) $rss_feed->channel->title ;
                                               $rss_link  = (string) $rss_feed->channel->link  ;
                                               $rss_cat   = (string) $rss_feed->channel->category  ;
                                               $rss_image = (string) $rss_feed->channel->image->url  ;
                
                                               $rss_summary =
                                                            array
                                                            (
                                                              'info' =>
                                                                        array(
                                                                                'title'=>$rss_title ,
                                                                                'link'=>$rss_link ,
                                                                                'cat'=>$rss_cat ,
                                                                                'image'=>$rss_image
                                                                                ) ,
                                                              'item' =>  array()
                
                                                            ) ;
                
                
                
                                               foreach($rss_feed->channel->item as $item)
                                                       {
                
                                                           if($item->enclosure && $item->enclosure->attributes())
                                                                {
                                                                    $image0 = $item->enclosure->attributes() ;
                                                                    $image_url = $image0 ['url'] ;
                                                                }
                
                                                          $rss_summary['item'][] =
                                                                                    array(
                                                                                        'title' => (string) $item->title ,
                                                                                        'description' => (string) $item->description ,
                                                                                        'link' => (string) $item->link ,
                                                                                        'date' => (string) $item->pubDate ,
                                                                                        'image' => (string) $item->image ,
                                                                                        'image2' =>  (string) $image0
                                                                                    ) ;
                                                       }
                
                                                if($return == 'json')
                                                       {
                                                         return json_encode($rss_summary) ;
                                                       }
                                                elseif($return == 'serialize')
                                                       {
                                                         return serialize($rss_summary) ;
                                                       }
                                                elseif($return == 'xml')
                                                       {
                                                         return xml_encode($rss_summary) ;
                                                       }
                                                else
                                                       {
                                                         return $rss_summary ;
                                                       }
                
                                            }
                                        else
                                            {
                                              $this->xml_errors['fetch'] = 'No Xml Content' ;
                                            }
                                    }
                
                             protected function connect($link)
                                    {
                                      if(!filter_var($link, FILTER_VALIDATE_URL))
                                              {
                                                $this->xml_errors['connect'] = 'Not Vaild Link To Get data' ;
                                                return false ;
                                              }
                                      if(function_exists('curl_init'))
                                           {
                                             $cu = curl_init();
                                             curl_setopt($cu, CURLOPT_URL, $link);
                                             curl_setopt($cu, CURLOPT_SSL_VERIFYPEER, false);
                                             curl_setopt($cu, CURLOPT_SSL_VERIFYHOST, false);
                                             //curl_setopt($cu, CURLOPT_REFERER, "http://www.tjreb.com");
                                             //curl_setopt($cu, CURLOPT_HEADER, true);
                                 //curl_setopt($cu, CURLOPT_FOLLOWLOCATION, false);
                                 curl_setopt($cu, CURLOPT_RETURNTRANSFER, TRUE);
                                             $co = curl_exec($cu) ;
                                               if($co)
                                                    {
                                                        $con = $co ;
                                                    }
                                               else
                                                    {
                                                      $this->xml_errors['connect'] = 'No Result From Curl' ;
                                                      $this->xml_errors['curl']  = curl_error($cu);
                                                    }
                                              curl_close($cu) ;
                                              return $con ;
                                           }
                
                                    if(!$con and function_exists('ini_get'))
                                        {
                
                                             $url_fopen = ini_get('allow_url_fopen') ;
                
                                             if($url_fopen == 0)
                                                {
                                                   if(function_exists('ini_set'))
                                                        {
                                                          ini_set('allow_url_fopen', 1) ;
                                                        }
                                                   $check_fopen = 1 ;
                                                }
                                             else
                                                {
                                                   $check_fopen = 0 ;
                                                }
                
                                             if($check_fopen == 1)
                                                {
                                                  $url_fopen = ini_get('allow_url_fopen') ;
                                                }
                
                                             if($url_fopen == 1)
                                                {
                
                                                  if(function_exists('file_get_contents') and !$con)
                                                   {
                                                        $con = @file_get_contents($link) ;
                                                        if($con)
                                                            {
                                                              return $con ;
                                                            }
                                                       else
                                                            {
                                                              $this->xml_errors['connect'] = 'No Result From file_get_contents' ;
                                                            }
                                                   }
                
                                              elseif(function_exists('readfile') and !$con)
                                                   {
                                                        $con = @readfile($link);
                                                        if($con)
                                                            {
                                                              return $con ;
                                                            }
                                                       else
                                                            {
                                                              $this->xml_errors['connect'] = 'No Result From readfile' ;
                                                            }
                                                   }
                
                                              elseif(function_exists('file') and !$con)
                                                   {
                                                        $con = @file($link)  ;
                                                        if($con)
                                                            {
                                                              return  $con ;
                                                            }
                                                       else
                                                            {
                                                              $this->xml_errors['connect'] = 'No Result From file' ;
                                                            }
                                                   }
                
                                                }
                                        }
                
                                      if(!$con)
                                           {
                                             $this->xml_errors['connect'] = 'Curl And Allow Url Fopen Disabled On Server' ;
                                             return false ;
                                           }
                                    }
                
                             public function get_error()
                                    {
                                       return $this->xml_errors ;
                                    }
                
                        }
                
                
                if(isset($_GET['feed']))
                    {
                       $url = addslashes($_GET['feed']) ;
                    }
                else
                    {
                       $url = 'http://rss.cnn.com/rss/edition_meast.rss' ;
                    }
                
                $fetch = $_GET['fetch'] ;
                $stack = $_GET['stack'] ;
                
                $xml = new xml_grabber($url) ;
                
                /*
                 http://www.youm7.com/new3agelrss.asp
                 http://www.youm7.com/newtkarirrss.asp
                 http://www.almasryalyoum.com/rss_feed_term/223241/rss.xml
                 http://gdata.youtube.com/feeds/api/playlists/18A7E36C33EF4B5D?v=2
                 http://rss.cnn.com/rss/edition_meast.rss
                 https://www.facebook.com/feeds/page.php?format=atom10&id=40796308305
                 https://www.facebook.com/feeds/page.php?format=rss20&id=40796308305
                 http://www.fwasl.com/feed
                 https://www.facebook.com/feeds/page.php?format=atom10&id=378156838895039
                 */
                
                if(isset($stack))
                {
                  $xml -> xml_stack = intval($stack) ; 
                }   
                
                
                $res    = $xml -> load()    ;
                
                $result = $xml -> fetch($fetch)   ;
                
                if($result)
                    {
                      print_r ( $result ) ;
                    }
                else
                    {
                      print_r ( $xml->get_error() ) ;
                    }
                
                ?>
                

                推荐答案

                你不能轻易绕过 Cloudflare.但是,您可以破解保护系统.:)

                You can't easily bypass Cloudflare. However you can hack the protection system. :)

                首先,解析页面(Cloudflare 保护页面)并计算 3+13*7(很可能每个请求都会有所不同).

                First, parse the page (Cloudflare protection page) and calculate 3+13*7 (most probably this will be different for each request.) in

                $(function(){setTimeout(
                            function(){
                                $('#jschl_answer').val(3+13*7);
                                $('#ChallengeForm').submit();
                            },
                            5850
                )});
                

                然后使用您从解析数据中获得的#ChallengeForm 中的jschl_vc"值和jschl_answer"值作为 3+13*7 发送发布请求.然后尝试使用 Cloudflare 添加的 cookie 值再次获取该页面.添加 Cloudflare 白名单后,您将不会再看到该页面.

                Then send post request the same page with "jschl_vc" value from #ChallengeForm which you got from parsed data and "jschl_answer" value as 3+13*7. And then try to fetch the page again with the cookie value that Cloudflare added. When you're added Cloudflare whitelist, you won't see that page anymore.

                这篇关于curl:由于 CloudFlare,无法从网站获取 RSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  • <bdo id='ZWRVD'></bdo><ul id='ZWRVD'></ul>
                  • <tfoot id='ZWRVD'></tfoot>

                        <legend id='ZWRVD'><style id='ZWRVD'><dir id='ZWRVD'><q id='ZWRVD'></q></dir></style></legend>

                        <small id='ZWRVD'></small><noframes id='ZWRVD'>

                            <tbody id='ZWRVD'></tbody>
                          <i id='ZWRVD'><tr id='ZWRVD'><dt id='ZWRVD'><q id='ZWRVD'><span id='ZWRVD'><b id='ZWRVD'><form id='ZWRVD'><ins id='ZWRVD'></ins><ul id='ZWRVD'></ul><sub id='ZWRVD'></sub></form><legend id='ZWRVD'></legend><bdo id='ZWRVD'><pre id='ZWRVD'><center id='ZWRVD'></center></pre></bdo></b><th id='ZWRVD'></th></span></q></dt></tr></i><div id='ZWRVD'><tfoot id='ZWRVD'></tfoot><dl id='ZWRVD'><fieldset id='ZWRVD'></fieldset></dl></div>