I am trying to get some values from similarweb using curls and simple_html_dom, but i can't grab only the value that i want. It gives me outpt all the page.
I am using the code bellow (this code works for other sites).
<?php
header('Content-Type: text/html; charset=utf-8');
require_once ('url_to_absolute/simple_html_dom.php');
$url = 'https://www.similarweb.com/website/bbc.com/#overview';
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_REFERER, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201');
$result = curl_exec($curl);
curl_close($curl);
$html = new simple_html_dom();
$html->load_file($result);
$div = $html->find('div.wa-rank-list__value',0)->outertext;
echo $div;
?>
I am trying to capture the value below:
Please give me a help.
<?php
header('Content-Type: text/html; charset=utf-8');
$url = 'http://www.similarweb.com/website/bbc.com/#overview';
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_REFERER, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201');
$result = curl_exec($curl);
curl_close($curl);
preg_match_all('@<p class="wa-rank-list__value"><small>#</small>(.*?)</p>@si',$result,$r);
echo $r[1][1];
?>