sábado, 31 de diciembre de 2016

scrapping the first 2 pages of freelancer.com

<?php
$offset=1;
$increment=1;
$list=array();
$data=shell_exec("curl https://www.freelancer.com/jobs/s-Asterisk_PBX-VoIP/$offset/?cl=l-en-es | grep -w \"https://www.freelancer.com/projects\"");
$info=explode("\n",$data);
foreach($info as $key=> $value) {

if(!empty($value)){

//echo " $key : $value<br>";

$list[]=$value;

}
}


if(end($list)){

$offset+=$increment;
$data=shell_exec("curl https://www.freelancer.com/jobs/s-Asterisk_PBX-VoIP/$offset/?cl=l-en-es | grep -w \"https://www.freelancer.com/projects\"");
$info=explode("\n",$data);
foreach($info as $key=> $value) {

if(!empty($value)){

//echo " $key : $value<br>";

$list[]=$value;

}
}


}

//new block to display   both pages merges


foreach($list as $key=> $value) {

//echo ($key+1)." ".trim(strip_tags($value,"<a>"));

echo " $key  $value<br><br>";
}


?>



No hay comentarios:

Publicar un comentario