index.php
<?php
include_once('libs/SQL.php');
include_once('libs/curl_query.php');
include_once('libs/simple_html_dom.php');
$html = curl_get('https://vk.com/mudachyo');
$dom = str_get_html($html);
$courses = $dom->find('.post_date');
foreach ($courses as $cours){
$a = $cours->find('a',0);
$url = str_replace('/','',$a->href);
$one = curl_get('https://vk.com/mudachyo?w='.$url);
$one_dom = str_get_html($one);
$like = $one_dom->find('.post_full_like',0);
echo $like->plaintext.'<br>';
}
``````php
curl_query.php
<?php
function curl_get($url, $refer = 'http://www.google.com'){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$data=curl_exec($ch);
curl_close($ch);
return $data;
}
``````php
Pokazuje:
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
4,215 Show likes 79 Show shared copies
``````php
Problem polega na tym, jak zrobić, żeby wyciągało like (numer) z innych bloków, a nie z tego samego.
Przykład:
4,215 Show likes 79 Show shared copies
637 Show likes 79 Show shared copies
220 Show likes 79 Show shared copies
520 Show likes 79 Show shared copies
840 Show likes 79 Show shared copies
700 Show likes 79 Show shared copies
900 Show likes 79 Show shared copies
``````php
Nie mogę znaleźć błąd. Zmienna $one jest co raz inna, a parsuje tylko z pierwszej strony.