title: Making file_get_content faster and skip 404 or non existing pages
body: <p>Currently the process takes a while to run but it also runs into a few 404 errors due to some files being deleted over time. I need to try to make this run faster and also have it skip all 404 or non-existing pages. Right now, when it skips pages. It will produce a url with a blank value</p>
  
  <p>ex</p>
  
  <blockquote>
    <p><a href="https://widget.mcf.li/project/.json" rel="nofollow">https://widget.mcf.li/project/.json</a></p>
  </blockquote>
  
  <p>I would need it to produce anything.</p>
  
  <pre><code>    $ch = curl_init();
  
      // set url
      curl_setopt($ch, CURLOPT_URL, "bot.notenoughmods.com/1.8.9.json");
  
      //return the transfer as a string
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
  
      // $output contains the output string
    $json = json_decode(curl_exec($ch), true);
  
  //Get itesm from NEM API
  foreach($json as $item) {
      $link = $item['longurl'];
  
      //Process for FQDN
      $link = preg_replace("/htt.{1,2}:\/\/(.+?[\.\-])*(\w{1,61}\.[a-zA-Z]{2,})\/.*/i", "$2", $link);
      //If its curse.com, process normally
      if ($link == 'curse.com') {
          $url = $item['longurl'];
          $newurl = explode("http://www.curse.com", $url);
          echo 'https://widget.mcf.li' . $newurl[1] . '.json &lt;br /&gt;';
      } 
  
  //If its curseforge.com, process HTML
      if ($link == 'curseforge.com') {
      $html = @file_get_contents($item['longurl']);
      //Check if URL gives 404
      if (empty($html)){
          return;
      } else {
          preg_match('%&lt;li class="view-on-curse"&gt;\s+&lt;a href="http:\/\/curse\.com\/project\/(?P&lt;id&gt;.*)"&gt;\s+View on Curse\.com\s+&lt;\/a&gt;\s+&lt;\/li&gt;%', $html, $matches);
          echo 'https://widget.mcf.li/project/' . $matches['id'] . '.json &lt;br /&gt;';
  } 
  }
  }
  </code></pre>