How to parse from tag to tag?

Wrote a script for the soap parser:

<?  
$handler=fopen('javabitz.txt','a+'); 
  for($i=1;$i<3000;$i++){ //  1  3000 
    $filename = 'http://www.***.ru/scr.php?num='.$i;  
    echo $i.". ";  
    $str = file_get_contents($filename);  
    preg_match_all('|href="mailto:([^"]*)"|is',$str,$out);  
    if(empty($out[1][0])) echo " ";  
    else{  
      echo " get ".$out[1][0];  
      fwrite($handler,$out[1][0]."\n");  
    }  
    echo "\n";  
  }  
  fclose($handler);  
?>

How to make it so that we parse from the <body>tag to </body>in preg_match_all.

Thanks in advance 🙂


Answer 1, authority 100%

preg_match_all('/<body[^>]*>(.*)<\/body>/', str_replace("\n", '', $str), $out);
//   $out[1][0]

Answer 2

"|\<body\>href="mailto:([^"]*)\<\/body\>|"

It seems so…