[urls] 'trekking / tourism' => [ 'https://www.nepalhikingteam.com/', 'https://www.sevensummittreks.com/', 'https://www.welcomenepaltreks.com/', 'https://www.greenvalleynepaltreks.com/', 'https://www.thenepaltrekkingcompany.com/', 'https://taan.org.np/', 'https://ntb.gov.np/', ], 'health / clinics' => [ 'https://www.kdh.com.np/', 'https://dent-inn.com/', 'https://www.smilenepal.com/', 'https://kantipurdental.edu.np/', 'https://www.phectnepal.org/', ], 'hospitality' => [ 'https://hotelthamel.com/', 'https://www.hotelyakandyeti.com/', 'https://www.hotelhimalaya.com/', 'https://www.dwarikas.com/', ], 'news / media' => [ 'https://www.onlinekhabar.com/', 'https://ekantipur.com/', 'https://www.setopati.com/', 'https://myrepublica.nagariknetwork.com/', 'https://kathmandupost.com/', 'https://english.insurancekhabar.com/', 'https://bankingnews.com.np/', ], 'finance / commerce' => [ 'https://www.sharesansar.com/', 'https://www.nrb.org.np/', 'https://daraz.com.np/', 'https://www.hamrobazaar.com/', 'https://esewa.com.np/', 'https://khalti.com/', ], 'education / institutions' => [ 'https://tribhuvan-university.edu.np/', 'https://ku.edu.np/', 'https://www.pu.edu.np/', 'https://moe.gov.np/', ], 'seo & digital agencies' => [ 'https://seoexpertinnepal.com/', 'https://aviralacharya.com.np/', 'https://www.clickbenz.com/', 'https://krizmatic.com/', 'https://kathmanduinfotech.com/', 'https://dipakpaneru.com.np/', 'https://baamaconsultant.com.np/', 'https://pigeonwebsolutions.com/', ], ]; /* ------------------------------------------------------------------ */ function fetchOne(string $url): array { $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, CURLOPT_HEADER => true, CURLOPT_TIMEOUT => 30, CURLOPT_CONNECTTIMEOUT => 12, CURLOPT_SSL_VERIFYPEER => false, // we record TLS problems, not enforce them CURLOPT_ENCODING => '', // advertise gzip/br so we can see if it is used CURLOPT_USERAGENT => 'Mozilla/5.0 (Linux; Android 12; SM-A125F) AppleWebKit/537.36 ' . '(KHTML, like Gecko) Chrome/120 Mobile Safari/537.36', ]); $raw = curl_exec($ch); $err = curl_error($ch); $info = curl_getinfo($ch); curl_close($ch); if ($raw === false) { return ['ok' => false, 'error' => $err, 'url' => $url]; } $hsize = $info['header_size']; return [ 'ok' => true, 'url' => $url, 'final_url' => $info['url'], 'code' => $info['http_code'], 'redirects' => $info['redirect_count'], 'ttfb' => $info['starttransfer_time'], 'total_time' => $info['total_time'], 'size' => $info['size_download'], 'headers' => substr($raw, 0, $hsize), 'body' => substr($raw, $hsize), ]; } function analyse(array $r): array { $h = $r['headers']; $b = $r['body']; $out = []; $out['url'] = $r['url']; $out['final_url'] = $r['final_url']; $out['code'] = $r['code']; $out['redirects'] = $r['redirects']; $out['ttfb_ms'] = (int)round($r['ttfb'] * 1000); $out['html_bytes'] = $r['size']; // HTTPS actually enforced (the final URL after following redirects) $out['https'] = str_starts_with($r['final_url'], 'https://'); // Transfer compression $out['compressed'] = (bool)preg_match('#^content-encoding:\s*(gzip|br|deflate|zstd)#mi', $h); // preg_match('#]*\blang=["\']([^"\']+)#i', $b, $m); $out['lang'] = $m[1] ?? null; // Mobile viewport $out['viewport'] = (bool)preg_match('#]+name=["\']viewport["\']#i', $b); // Title preg_match('#