Hello, I'm trying to return this code in JSON, I just want some specific fields eg: Operator, type, portability and state.
<?php
//header('Content-type: application/json');
$post = ['tel' => $_GET['enviar'] , 'bto' => 'submit'];
$ch = curl_init('http://consultanumero.info/consulta');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'http://consultanumero.info/consulta',
'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
],
CURLOPT_POSTFIELDS => $post,
CURLOPT_ENCODING => '',
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS
]);
//json_encode($ch);
echo $output = curl_exec($ch);
?>
This is my code and the return:
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8" />
<title>Consulta Número</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta property="fb:app_id" content="519584384854184" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="/css/base.css?1409782940" media="all" />
<link rel="prerender" href="http://consultanumero.info/" />
<script src="/js/base.js?1407968504" async></script>
<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async></script>
<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
ga("create", "UA-16052289-33", "auto");
ga("send", "pageview");
</script>
</head>
<body class="int consulta">
<div id="geral">
<div id="cab">
<h1><a href="/">Consulta Número</a></h1>
<p>Descubra a operadora atual de qualquer número, celular ou telefone fixo!</p>
</div>
<div id="ctd">
<div class="prop">
<ins class="adsbygoogle" style="display: inline-block" data-analytics-uacct="UA-16052289-33" data-ad-client="ca-pub-3806187316222201" data-ad-slot="9873102520"></ins>
<script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
</div>
<div class="resultado">
<div class="a">
<img src="/img/op/claro.png" alt="Claro" title="Claro" />
<div class="tel">(11) 97612 0592</div>
</div>
<div class="b">
<p><span>Tipo <span>»</span></span> Celular</p>
<p><span>Portabilidade <span>»</span></span> Não</p>
<p><span>Estado <span>»</span></span> São Paulo (SP)</p>
<p><span>Região <span>»</span></span> São Paulo e região metropolitana</p>
</div>
</div>
<button class="li" onclick="ga('send', 'event', 'Consulta', 'Ligar'); window.location = 'tel:011976120592'">Ligar</button>
<button class="nc" onclick="ga('send', 'event', 'Consulta', 'Nova'); window.location = '/'">Nova Consulta</button>
</div>
In the case I would only like this return in JSON.
<div class="resultado">
<div class="a">
<img src="/img/op/claro.png" alt="Claro" title="Claro" />
<div class="tel">(11) 97612 0592</div>
</div>
<div class="b">
<p><span>Tipo <span>»</span></span> Celular</p>
<p><span>Portabilidade <span>»</span></span> Não</p>
<p><span>Estado <span>»</span></span> São Paulo (SP)</p>
<p><span>Região <span>»</span></span> São Paulo e região metropolitana</p>
</div>
</div>