0

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>';
}

simple_html_dom.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;
}

Выводит:

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

Как сделать так что бы парсело другие блоки а не один и тот же? Что то в этом роде.Пример:

 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 
2
  • Например воспользоваться API можно и не извращаться 25 мая 2017 в 21:01
  • @АлексейШиманский можно и так пришло в голову это когда уже написал код.Но интересно можно ли получить данные таким способом?
    – Daizer
    25 мая 2017 в 21:04

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.