Answer the question
In order to leave comments, you need to log in
How to loop through classes in 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";
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question