I have a PHP web crawler which works perfectly fine (for now)
It extracts forum questions and their links from a site and pastes it in my site.
so, i been trying to make it do the same except this time, i want it to skip 2 line from the extracting site. so instead of getting all the statements from the site, it will start from statement 3.
My code goes as:
<?php
function get_data($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
return $result;
}
$returned_content = get_data('http://www.usmle-forums.com/usmle-step-1-forum/');
$first_step = explode( '<tbody id="threadbits_forum_26"' , $returned_content );
$second_step = explode('</tbody>', $first_step[1]);
$third_step = explode('<tr>', $second_step[0]);
// print_r($third_step);
foreach ($third_step as $key=>$element) {
$child_first = explode( '<td class="alt1"' , $element );
$child_second = explode( '</td>' , $child_first[1] );
$child_third = explode( '<a href=' , $child_second[0] );
$child_fourth = explode( '</a>' , $child_third[1] );
$final = "<a href=".$child_fourth[0]."</a></br>";
echo '<li target="_blank" class="itemtitle">';
if($key < 5 && $key > 2 && rand(0,1) == 1) {
echo '<span class="item_new">new</span>';
}
echo $final;
echo '</li>';
if($key==10) {
break;
}
}
?>
Any help is appreciated..