简单 Html Dom 库在本地服务器上工作,但在大多数实时服务器上不工作

Simple Html Dom library works on local server but not in mostly live server

我正在使用 curl 进行网页抓取和解析 html 使用简单的 html dom 库,它非常简单。但我的主要问题是这个库在本地服务器上运行流畅,但在实时服务器上运行不流畅。奇怪的是它可以在 000webhost 主机上正常工作,但是当我使用其他付费主机如 godaddy、namecheap 等时

付费 Hostinger 计划也不支持。我联系了 godaddy 支持,他们说您需要联系您的开发人员,这不是托管问题。

我在互联网上搜索了很多,发现我需要启用 php 扩展 'mbstring',但同样的问题。

当我搜索数据时,它给我一个空数组,如 'Array'。我尝试了所有方法,但无法获得任何解决方案,也无法解决问题。

<?php

error_reporting(0);

                    
                    if (isset($_POST['submit'])) 
                    {
                        $search = $_POST['cnic'];
                        if (strlen($search) < 12) 
                        {
                          $search = substr($search, 1);
                        }
                        
                        $url = "https://allcstech.com/tele/search-result.php";
                        $ch = curl_init();
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
                        curl_setopt($ch, CURLOPT_TIMEOUT, 40);
                        curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
                        curl_setopt($ch, CURLOPT_URL, $url);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "cnnum=$search");
                        $html = curl_exec($ch);
                                
                                include 'dfapi/simple_html_dom.php';
            $dom = new simple_html_dom();
            $dom->load($html);
            
            $firstname = $dom->find('td',3);
            
            $lastname = $dom->find('td',5) ;
            
            $cnic = $dom->find('td',7);
            
            $number = $dom->find('td',1);
            $mod = "<strong>0</strong>".$number;
            
            $address = $dom->find('td',9);
            
            // $address1 = $dom->find('#address1',0);

            // $city = $dom->find('#city',0);

            if(!empty($firstname)||!empty($fullname)||!empty($lastname)||!empty($cnic)||!empty($number)||!empty($number))
            {
                
            }
            else
            {
                $msg = "No record Found";
            }
            

            foreach($dom->find('table') as $e)
              $otherdata = $e;
            $otherdata1 = $dom->find('table',1);
            
}
                    
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DataFinder</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<style>
    @font-face { font-family: Jameel Noori Nastaleeq; src: url('Jameel Noori Nastaleeq.ttf'); } 
    img[src*="https://cdn.000webhost.com/000webhost/logo/footer-powered-by-000webhost-white2.png"] {
display: none;}
body {
  font-family: Arial;
}

* {
  box-sizing: border-box;
}

table
{
  color: white;
  text-transform: capitalize;
}
td
{
  text-align: right;
  margin-left: 20px;
}

form.example input[type=number] {
  padding: 10px;
  font-size: 17px;
  border: 1px solid grey;
  float: left;
  width: 80%;
  background: #f1f1f1;
}

form.example button {
  float: left;
  width: 20%;
  padding: 10px;
  background: #2196F3;
  color: white;
  font-size: 17px;
  border: 1px solid grey;
  border-left: none;
  cursor: pointer;
}

form.example button:hover {
  background: #0b7dda;
}

form.example::after {
  content: "";
  clear: both;
  display: table;
}

/* Hide HTML5 Up and Down arrows. */
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
 
input[type="number"] {
    -moz-appearance: textfield;
}
#alert { font-family: Jameel Noori Nastaleeq, sans-serif;color: #fff }
</style>

<script>
    $(document).ready(function() {
        $("#hide").hide();
        $("#again").hide();
        $("#show").click(function() {
            $("#hide").show();
            $("#show").hide();
            $("#again").show();
        });
        $("#show").click(function() {
            $("#hide").show();
        });
        $("#again").click(function() {
            $("#hide").hide();
            $("#again").hide();
            $("#show").show();
        });
        
    });
</script>
<body style="background-color: orange">

    <div class="container mt-2">

        <span id="alert"><span id="again" style="cursor: pointer;"> (Hide this) </span> <span id="show" style="cursor: pointer;">...</span>ڈیٹافائنڈر گورنمنٹ کی طرف سے بلیک لسٹ میں ڈالا  <span id="hide">گیا،جس کی وجہ سے ہمیں سرور میں وی پی این لگانا پڑا،وی پی این کی وجہ سے ڈیٹا سرچ میں ٹائم لگ سکتا ہے۔کسی بھی نمبر یا آئی ڈی کارڈ کا ڈیٹآ دو یا تین مرتبہ سرچ کرنے سے شو نہ ہو تو مطلب اس کا ڈیٹا نہیں ہے۔  </span></span>

        <form action="numdb.php" method="post" class="example">

          <input type="number" placeholder="03xxxxxxxxx" name="cnic" autocomplete="off" minlength="10" value="<?php if(isset($_POST['submit'])) echo $_POST['cnic']; ?>">
          <button type="submit" name="submit"><i class="fa fa-search"></i></button>
    
        </form>
        <?php echo $msg; ?>

        <div class="mt-4">
            <strong class="float-left text-white">Name:</strong>
            <span class="float-right text-white"><?php echo $firstname." ".$lastname." ".$fullname; ?></span>
            <br><br>
            <strong class="float-left text-white">CNIC:</strong>
            <span class="float-right text-white"><?php echo $cnic; ?></span>
            <br><br>
            <strong class="float-left text-white">Number:</strong>
            <span class="float-right text-white"><?php echo $mod; ?></span>
            <br><br>
            <strong class="float-left text-white">Address:</strong>
            <span class="float-right text-white"><?php echo $address." ".$address1." ".$city; ?></span>
            <br><br><br>
            
                <!--<center>-->
                <!--    <br>-->
                <!--    <h3 style="width: 100%;height: 30px;color: white;background-color: orange;display: block;">Possible Data</h3>-->
                <!--    <br>-->
                <!--</center>-->
            

            <strong><?php echo $otherdata; ?></strong>
            <br><br>
            <hr>
    <strong><?php echo $otherdata1; ?></strong>
        </div>
        

    </div>

<center>
    <div style="color: white;size: 15px;margin: 10px">
      <span>
        Install DataFinder Application and Get a lot other services like:
      </span>
      <ul>
        <li>Family Tree</li>
        <li>Cnic Copy</li>
        <li>Live Location</li>
        <li>Call History</li>
        <li>IMEI Tracing</li>
        <span>Its paid service and you need to purchase registration and get 24/7 customer support</span>
      </ul>
    </div>

    <h4><a href="href="https://play.google.com/store/apps/details?id=com.darkcoderz.datafinderService"">Download DataFinder</a></h4></center>

    
</body>
</html>```

尝试以下 curl 设置,我认为问题出在 curl 而不是 html_simple_dom。

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 40);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "cnnum=$search");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    $html = curl_exec($ch);

    curl_close($ch);