Skip to content

Commit

Permalink
[PicukiBridge] Try to fix the bridge (#4262)
Browse files Browse the repository at this point in the history
This is a try to fix the bridge HTML parsing
  • Loading branch information
sysadminstory authored Sep 11, 2024
1 parent 40041dd commit d9316cd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bridges/PicukiBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ public function collectData()
}

$count = 0;
foreach ($html->find('.box-photos .box-photo') as $element) {
foreach ($html->find('div[class=.box-photo][data-s=media]') as $element) {
// skip ad items
if (in_array('adv', explode(' ', $element->class))) {
continue;
}

$url = urljoin(self::URI, $element->find('a', 0)->href);
$html = getSimpleHTMLDOMCached($url);
$url = $element->find('a', 0)->href;
$html_single = getSimpleHTMLDOMCached($url);
$sourceUrl = null;
if (preg_match($re, $html, $matches) > 0) {
if (preg_match($re, $html_single, $matches) > 0) {
$sourceUrl = 'https://instagram.com/p/' . $matches[1];
}

$author = trim($element->find('.user-nickname', 0)->plaintext);
//$author = trim($element->find('.single-photo-nickname', 0)->plaintext);

$date = date_create();
$relativeDate = str_replace(' ago', '', $element->find('.time', 0)->plaintext);
date_sub($date, date_interval_create_from_date_string($relativeDate));

$description = trim($element->find('.photo-description', 0)->plaintext);
$description = trim($element->find('.photo-action-description', 0)->plaintext);

$isVideo = (bool) $element->find('.video-icon', 0);
$videoNote = $isVideo ? '<p><i>(video)</i></p>' : '';
Expand All @@ -91,7 +91,7 @@ public function collectData()

$this->items[] = [
'uri' => $url,
'author' => $author,
/*'author' => $author,*/
'timestamp' => date_format($date, 'r'),
'title' => strlen($description) > 60 ? mb_substr($description, 0, 57) . '...' : $description,
'thumbnail' => $imageUrl,
Expand Down

0 comments on commit d9316cd

Please sign in to comment.