@almenovr

Как циклом перебирать классы в phpQuery?

<?php
require 'phpQuery.php';


function print_arr($arr){
    echo '<pre>' . print_r($arr, true) . '</pre>';
}

function get_content($url, bool $isPost = false, $data = []){
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    if ($isPost) {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    }
    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ . '/cookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ . '/cookie.txt');
    curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36');
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}

$url_auth = 'https://www.facebook.com/login/';
$url = 'https://www.facebook.com/groups/websarafan.ru/';
$auth_data = [
    'email' => '',
    'pass' => '',
];

$data = get_content($url_auth, true, $auth_data);
$data = get_content($url, false);

$doc = phpQuery::newDocument($data);

	
foreach ($doc->find('._3ccb') as $post) {

	echo "1";
}


Пытаюсь спарсить посты в группе в фейсбуке, через код смотрю хранятся в классе _3ccb, но почему то не могу найти их так. В чем ошибка?
  • Вопрос задан
  • 62 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы