par bagou450 » 25 oct. 2021, 14:40
Code : Tout sélectionner
$url = 'Mon URL'; $pattern = '#(?:src|href|path|xmlns(?::xsl)?)\s*=\s*(?:"|\')\s*(.+)?\s*(?:"|\')#Ui'; $subject = file_get_contents($url); preg_match_all($pattern, $subject, $matches, PREG_PATTERN_ORDER); foreach($matches[1] as $match) { if (str_starts_with($match, './')) { $hrefresult= str_replace("./", "", $match); $hrefresult2= strtok($artifactslink, '-'); $tablo_liens[] = array( "hrefresult"=>$hrefresult, "another things"=>$hrefresult2 ); } } echo $tablo_liens;
par or 1 » 25 oct. 2021, 13:53
par bagou450 » 25 oct. 2021, 12:49
par @rthur » 25 oct. 2021, 10:58
$tablo_liens[] = array( "hrefresult"=>"firsthrefresulthere", "another things"=>"here" );
par bagou450 » 25 oct. 2021, 10:48
$html = file_get_contents('Ma page web'); $dom = new DOMDocument; @$dom->loadHTML($html); $links = $dom->getElementsByTagName('href'); foreach ($links as $link){ }
{ [ "hrefresult": "firsthrefresulthere", "another things": "here" ], [ "hrefresult": "secondhrefresulthere", "another things": "here" ] }