Я хочу извлечь стоимость покупки и продажи из этот Веб-сайт
Как я могу сделать это, используя file_get_contents () в PHP
Например,
$abc = file_get_content("https://www.unocoin.com/trade?all");
Теперь, как я могу извлечь из нее стоимость покупки и продажи каждые 2 минуты?
Здесь, если вы хотите извлечь данные с другой веб-страницы, чем вы используете php curl
пример
function curl_download($Url){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
$ch = curl_init();
// Now set some options (most are optional)
// Set URL to download
curl_setopt($ch, CURLOPT_URL, $Url);
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
return $output;
}
print curl_download('https://www.unocoin.com/trade?all');
Для этого конкретного сайта данные кодируются в формате json, поэтому все, что вам нужно сделать, — и, похоже, нет никаких дополнительных требований к аутентификации, так как я могу просто перейти по ссылке и посмотреть данные.
$abc = file_get_content("https://www.unocoin.com/trade?all");
$decoded_abc=json_decode($abc);
$buy=$decoded_abc->buy;
$sell=$decoded_abc->sell;