How to get a data-count from a PHP / Web Scraping span

0

It turns out that for a job I need to get the number of tweets that have an "x" twitter account, to occupy the API I must wait for them to enable me account so it is not an option.

I am currently doing web scraping to the profile where I get to the following tag:

<span class="ProfileNav-value" data-count="176156" data-is-compact="true">176&nbsp;mil </span>

It turns out that I need to get the whole number that comes in data-count, this is my scraping code:

<?php 


require 'simple_html_dom.php';



$url= 'https://twitter.com/NombreUsuario'; //URL del usuario a obtener tweets
$html = file_get_html($url); //Obtemos todo el contenido 
$tweets = $html->find('div[class=ProfileNav]'); //Dentro del html recibido 
buscamos el div con la class ProfileNav

foreach ( $tweets as $tweet){

    $contenido = $tweet ->find('span[class="ProfileNav-value"]',0);

    echo $contenido;
}

?>

It works but it shows me the value that is seen in the front, if the user has a lot of tweets he shows it to me: 176 thousand for example.

    
asked by Leandro Pavez 02.10.2018 в 16:59
source

0 answers