true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects // CURLOPT_USERPWD => "$username:$passwd" ); $url = "http://api.in.com/active18/solr/rewamp/solr_search_watch_in.php?query=*:*&start=0&limit=1"; $data = initializeCurl($url); $xml = simplexml_load_string($data); $total_count = $xml->length; //$total_count =120; $offset=500; //echo "CNT=".$cnt; //exit; $g_documents=null; for($i=0;$i<$total_count;$i+=$offset){ // echo $i."---".$offset."\n"; $url = "http://api.in.com/active18/solr/rewamp/solr_search_watch_in.php?auto=1&query=*:*&start=$i&limit=$offset"; // $url = "http://api.in.com/active18/solr/rewamp/solr_search_watch_in.php?query=id:349f725bbd35a97e30cf70a3b982a26586e991ad&start=0&limit=100"; $data = initializeCurl($url); $xml = simplexml_load_string($data); $g_documents=array(); for($index=0,$j=$i;$j<$i+count($xml->item);$j++,$index++){ $entity = trim($xml->item[$index]->entity); $tags= trim($xml->item[$index]->tags); $category= trim($xml->item[$index]->category); $sub_category= trim($xml->item[$index]->sub_category); if(strlen($entity)!=0){ $arr_enty = explode(",",$entity); for($k=0;$kping()){ //print_r($g_documents); $solr->addDocuments($g_documents); $solr->commit(); } } function initializeCurl($link) { $ch = curl_init(); global $options; curl_setopt_array( $ch, $options ); curl_setopt($ch, CURLOPT_URL, $link); $output = curl_exec($ch); curl_close($ch); return $output; } function insert_doc($entity,$type){ global $g_documents; $document = new Apache_Solr_Document(); $document->query = strtolower($entity); $document->type = $type; array_push($g_documents,$document); } ?>