public function __invoke($url): string
{
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+
+
+
+ $headers = [];
+ $headers[] = "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0";
+ $headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
+ $headers[] = "Accept-Language: en-US,en;q=0.5";
+ $headers[] = "Accept-Encoding: gzip, deflate, br";
+
+ curl_setopt($ch,CURLOPT_ENCODING , "gzip");
+
+ curl_setopt($ch, CURLOPT_HTTPHEADER , $headers);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ $str = curl_exec($ch);
+
+ curl_close($ch);
+
+
$context = stream_context_create(
[
"http" => [
- "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
+// "header" => implode("\r\n", $headers),
+ "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36",
+
]
]
);
- $str = file_get_contents($url, false, $context);
+// $str = file_get_contents($url, false, $context);
if($str !== ''){
$str = trim(preg_replace('/\s+/', ' ', $str)); // supports line breaks inside <title>
preg_match("/<title>(.*)<\/title>/i",$str,$title); // ignore case