Answer the question
In order to leave comments, you need to log in
file_get_contents is not reading the page, why?
Good afternoon!
Tell me, why can not read some sites file_get_contents? www.example.com as in the example - reads, but www.baza-firm.com.pl - no.
Please tell me why and how to fix it.
Answer the question
In order to leave comments, you need to log in
I'm sure you should add a header to emulate a browser. Some kind of protection against spiders;)
<?php
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0\r\n"
)
);
$context = stream_context_create($opts);
file_get_contents('http://www.baza-firm.com.pl', false, $context)
1. what does file_get_contents output via var_dump?
2. what's in the headers?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question