Convert sitemap.xml file to urllist.txt file using PHP
If you create a script that can generate a sitemap.xml file, it doesn't make sense to adapt the script to create a urllist.txt file. The best solution is to use this sitemap.xml file to create urllist.txt. The script below will do exactly that.
$lines = file( 'sitemap.xml' ); $allMatches = array(); foreach ( $lines as $line_number => $line ) { $line = trim($line); preg_match_all( '/(?<=\<loc\>)(.*?)(?=\<\/loc\>)/U' , $line, $matches,PREG_SET_ORDER); if ($matches){ if ( $matches[ 0 ][ 0 ] != '' ) { $allMatches[] = $matches[ 0 ][ 0 ]; }; }; }; $list = '' ; foreach ( $allMatches as $url ) { $list .= $url. "\n" ; }; $fh = fopen( 'urllist.txt' , "w+" ); fwrite($fh, $list); fclose($fh); // Print the list to provide some feedback... echo $list;
The script works by first loading the file into an array with sitemap.xml using the file() function. The script then goes through all the items in the array and picks out
cheap atorvastatin 80mg & lt;a href="https://lipiws.top/"& gt;atorvastatin where to buy& lt;/a& gt; purchase lipitor online
Uqredq
2024-03-10