简体   繁体   English

从 Similarweb 获取特定值

[英]Grab Specific Values From Similarweb

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.我正在尝试使用 curls 和 simple_html_dom 从similarweb 获取一些值,但我不能只获取我想要的值。 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];
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM