@ 2015-09-11T12:42:12Z <?php
$t=time();
//csv file write
#$filename=date("Y-m-d",$t)."_work.csv";
$filename=$t."_data.csv";
$handle = fopen($filename, "w");
//Header for csv file
$business = array("Business Name" , "Address1" ,"City","State","Zip code","Address2","Phone" , "Website" ,"Yelp Url");
fputcsv($handle,$business);
$start=0;
$csv_records = array();
for ($i = 0; $i <= 100; $i++) {
$start=$i*10;//start count for pagination
$args = $_SERVER['argv'];
//$html = file_get_contents($args[1].'&start='.$start);
$html = file_get_contents('http://www.yelp.com/search?find_desc=tasty+burger&find_loc=San+Francisco%2C+CA&start=10', 'w');
if(!empty($html)){
$pokemon_doc = new DOMDocument();
libxml_use_internal_errors(TRUE); //disable libxml errors
$pokemon_doc->loadHTML($html);
libxml_clear_errors(); //remove errors for yucky html
$pokemon_xpath = new DOMXPath($pokemon_doc);
//get all the span's with an class for getting Url
$pokemon_row = $pokemon_xpath->query('/html/body//span[@class="indexed-biz-name"]/a');
$biz = array();
if($pokemon_row->length > 0){
foreach($pokemon_row as $row){
$biz['name'] = $row->nodeValue;
$url1 = $row->getAttribute("href");
$biz['yelp_url'] = "http://www.yelp.com".$url1;
$html1 = file_get_contents("http://www.yelp.com/".$url1);
$pokemon_doc1 = new DOMDocument();
libxml_use_internal_errors(TRUE);
$pokemon_doc1->loadHTML($html1);
libxml_clear_errors(); //remove errors for yucky html
$pokemon_xpath1 = new DOMXPath($pokemon_doc1);
//get all the h2's with an id
$pokemon_row1 = $pokemon_xpath1->query('/html/body//div[@class="mapbox-text"]/ul/li');
$biz['address'] = $pokemon_row1->item(0)->nodeValue;
$biz['phone'] = $pokemon_row1->item(2)->nodeValue;
if(preg_match('/Business website/',$pokemon_row1->item(3)->nodeValue)){
$biz['website']= $pokemon_row1->item(3)->nodeValue;
}
else{
$biz['website']= $pokemon_row1->item(4)->nodeValue;
}
//$biz['website'] ="http://".ltrim($bizwebsite,1);
/* ############# Code to remove extra spaces and new line chars*/
$line_out_name = preg_replace('/[\n\r]+/', '', $biz['name']);
$business_details_name = preg_replace('/[\s]+/', ' ', $line_out_name);
$line_out_address = preg_replace('/[\r]+/', '', $biz['address']);
$business_details_address = preg_replace('/[\s]+/', ' ', $line_out_address);
$business_address=explode(",",$business_details_address);
$add1=explode(" ",$business_address[0]);
$add=$add1[0]." ".$add1[1]." ".$add1[2];
$add1=$add1[3]." ".$add1[4];
$add2=explode("b/t",$business_address[1]);
$s=explode(" ",$add2[0]);
$state=$s[1];
$zip=$s[2];
$lastadd="b/t".$add2[1];
$line_out_phone = preg_replace('/[\n\r]+/', '', $biz['phone']);
$business_details_phone = preg_replace('/[\s]+/', ' ', $line_out_phone);
$business_details_phone = preg_replace('/Phone number/','', $business_details_phone);
$line_out_website = preg_replace('/[\n\r]+/', '', $biz['website']);
$business_details_website = preg_replace('/Business website/','', $line_out_website);
$business_details_website = preg_replace('/[\s]+/', '', $business_details_website);
$business_details_website = "http://".$business_details_website;
$business[0]= stripslashes(htmlspecialchars($business_details_name));
$business[1]= stripslashes($add);
$business[2]= stripslashes($add1);
$business[3]= stripslashes($state);
$business[4]= stripslashes($zip);
$business[5]= stripslashes($lastadd);
$business[6]= stripslashes($business_details_phone);
$business[7]= stripslashes($business_details_website);
$business[8]= stripslashes($biz['yelp_url']);
array_push($csv_records,($business[0]),$business[1],$business[2],$business[3],$business[4],$business[5],$business[6],$business[7],$business[8]);
if (false !== $handle) {
fputcsv($handle,$csv_records);
}
$csv_records = array();
} #foreach ends $pokemon_row
} #if ends $pokemon_row->length > 0
}#if(!empty($html))
$business1 = "";
}#for ($i = 1; $i < 5; $i++) end
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.2.8 0.027 0.004 16.38 7.2.6 0.015 0.013 17.14 7.2.0 0.014 0.011 19.63 7.1.20 0.012 0.011 16.18 7.1.10 0.022 0.007 18.63 7.1.7 0.004 0.008 17.45 7.1.6 0.007 0.018 20.03 7.1.5 0.014 0.003 17.11 7.1.0 0.013 0.080 22.86 7.0.20 0.008 0.003 17.18 7.0.10 0.020 0.037 20.46 7.0.9 0.017 0.087 20.38 7.0.8 0.010 0.083 20.30 7.0.7 0.013 0.040 20.42 7.0.6 0.020 0.080 20.54 7.0.5 0.017 0.063 20.77 7.0.4 0.023 0.067 20.45 7.0.3 0.023 0.087 20.41 7.0.2 0.010 0.057 20.43 7.0.1 0.013 0.057 20.54 7.0.0 0.020 0.073 20.30 5.6.28 0.013 0.063 21.46 5.6.25 0.017 0.093 21.16 5.6.24 0.013 0.057 21.07 5.6.23 0.010 0.057 21.12 5.6.22 0.020 0.077 21.07 5.6.21 0.010 0.043 21.21 5.6.20 0.007 0.047 21.42 5.6.19 0.013 0.090 21.50 5.6.18 0.020 0.043 21.28 5.6.17 0.023 0.097 21.53 5.6.16 0.030 0.090 21.39 5.6.15 0.013 0.053 21.36 5.6.14 0.010 0.077 21.52 5.6.13 0.013 0.090 21.40 5.6.12 0.020 0.073 21.50 5.6.11 0.017 0.090 21.34 5.6.10 0.010 0.083 21.28 5.6.9 0.010 0.047 21.38 5.6.8 0.020 0.087 21.02 5.6.7 0.013 0.057 20.80 5.6.6 0.017 0.083 20.81 5.6.5 0.020 0.073 20.79 5.6.4 0.017 0.080 20.78 5.6.3 0.023 0.077 20.66 5.6.2 0.023 0.073 20.83 5.6.1 0.020 0.053 20.73 5.6.0 0.017 0.047 20.85 5.5.38 0.023 0.067 21.04 5.5.37 0.017 0.040 20.93 5.5.36 0.013 0.090 20.89 5.5.35 0.010 0.057 20.89 5.5.34 0.023 0.077 21.10 5.5.33 0.023 0.080 21.24 5.5.32 0.030 0.060 21.24 5.5.31 0.023 0.043 21.25 5.5.30 0.027 0.077 21.20 5.5.29 0.023 0.077 21.25 5.5.28 0.017 0.043 21.23 5.5.27 0.013 0.087 21.25 5.5.26 0.013 0.073 21.38 5.5.25 0.010 0.070 21.08 5.5.24 0.023 0.083 20.77 5.5.23 0.017 0.077 20.49 5.5.22 0.013 0.073 20.59 5.5.21 0.020 0.083 20.52 5.5.20 0.013 0.063 20.50 5.5.19 0.023 0.077 20.64 5.5.18 0.020 0.077 20.49 5.5.16 0.030 0.070 20.40 5.5.15 0.030 0.097 20.58 5.5.14 0.027 0.073 20.66 5.5.13 0.020 0.083 20.60 5.5.12 0.020 0.073 20.50 5.5.11 0.030 0.070 20.57 5.5.10 0.023 0.063 20.52 5.5.9 0.017 0.047 20.47 5.5.8 0.017 0.077 20.60 5.5.7 0.017 0.063 20.46 5.5.6 0.027 0.073 20.34 5.5.5 0.030 0.070 20.53 5.5.4 0.013 0.047 20.48 5.5.3 0.010 0.070 20.55 5.5.2 0.017 0.057 20.48 5.5.1 0.013 0.083 20.59 5.5.0 0.007 0.053 20.54 5.4.45 0.020 0.040 19.66 5.4.44 0.013 0.093 19.94 5.4.43 0.010 0.083 19.71 5.4.42 0.023 0.070 19.72 5.4.41 0.017 0.047 19.57 5.4.40 0.007 0.073 19.43 5.4.39 0.020 0.077 19.42 5.4.38 0.013 0.077 19.36 5.4.37 0.017 0.073 19.43 5.4.36 0.013 0.073 19.36 5.4.35 0.013 0.053 19.31 5.4.34 0.013 0.050 19.44 5.4.32 0.010 0.050 19.46 5.4.31 0.017 0.080 19.27 5.4.30 0.023 0.080 19.43 5.4.29 0.027 0.077 19.31 5.4.28 0.020 0.090 19.31 5.4.27 0.010 0.087 19.31 5.4.26 0.020 0.080 19.43 5.4.25 0.027 0.070 19.41 5.4.24 0.023 0.040 19.36 5.4.23 0.030 0.063 19.43 5.4.22 0.033 0.030 19.30 5.4.21 0.023 0.073 19.44 5.4.20 0.020 0.060 19.30 5.4.19 0.017 0.053 19.36 5.4.18 0.030 0.063 19.41 5.4.17 0.023 0.053 19.25 5.4.16 0.020 0.087 19.39 5.4.15 0.033 0.070 19.27 5.4.14 0.020 0.060 16.86 5.4.13 0.010 0.047 16.58 5.4.12 0.017 0.043 16.86 5.4.11 0.027 0.090 16.81 5.4.10 0.013 0.070 16.70 5.4.9 0.027 0.067 16.65 5.4.8 0.017 0.077 16.82 5.4.7 0.020 0.067 16.68 5.4.6 0.013 0.077 16.78 5.4.5 0.030 0.063 16.74 5.4.4 0.023 0.080 16.58 5.4.3 0.017 0.080 16.66 5.4.2 0.020 0.073 16.74 5.4.1 0.023 0.040 16.61 5.4.0 0.017 0.063 16.33
preferences:dark mode live preview
39.42 ms | 401 KiB | 5 Q