<?php
header('Content-type: text/html; charset=utf-8');
function getcon($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
//$i='';
$arr=array(
//my array;
);
foreach($arr as $value){
$myFile = "$value.txt";
$urlGr=str_replace(" ","-",$value);
$fh = fopen($myFile, 'w') or die("can't open file");
$br='<br>';
fwrite($fh, $br);
$i=21;
while($i<=186){
if($i==1)
{$ap='';}
else{
$ap='page/'.$i.'/';
}
//$i = ($j * 16) - 16;
$content=getcon("URL/$urlGr/$ap");
//patern="[\s\S\w]*?";
//$patern="[\s]*([\s\S\w]+?)";
if(preg_match_all('~<td height="5" valign="top" class="titlestyle"><div align="center"><a href="[\s]*([\s\S\w]+?)" class="titlestyle"~i',$content,$matches)){
// echo '<pre>';
// print_r($matches[1]);
// echo '</pre>';
}
$i=$i+1;
foreach($matches[1] as $value){
// echo $value."<br>";
$value=$value.$br;
fwrite($fh, $value);
}
}
fclose($fh);
}
echo "OK";
?>