<?php

require_once __DIR__ . '/vendor/autoload.php';

use PHPHtmlParser\Dom;
use PHPHtmlParser\Options;

$options = new Options();
$options->setEnforceEncoding('utf8');

$url1 = 'https://13dl.me/list/popular/';
function scrape($counter,$options,&$element_a){
        $titles = array();
        $next = "";

        foreach($element_a as $line){
                if(preg_match('/title/',"$line")) {
                        $div = $line->find('div');
                        if(preg_match('/div/',"$div")) {
                                $titles[] = $div->text;
                        }else{
                                if(preg_match('/Next/',"$line")){
                                        $attr = 'href';
                                        $next = $line->$attr;
                                }
                        }
                }else{
                        ;
                }
        }

        unset($element_a);
        foreach($titles as $xxxx){
                $counter ++;
                echo $counter . " title :" . $xxxx . "\n";
        }
        unset($titles);
        return array("$next",$counter);
}

$counter = 0;
while($url1 != ''){
        if(preg_match('/http/',"$url1")) {
                $dom = new Dom();
                $dom->loadFromUrl($url1, $options);
                $element_a = $dom->find('a');
                list($url1,$counter) = scrape($counter,$options,$element_a,$db);
                unset($element_a);
                unset($dom);
        }
}
die('End');
?>
Edit Report
Pub: 16 Sep 2022 21:51 UTC
Edit: 17 Sep 2022 16:35 UTC
Views: 89