如何将其他网站的提取数据保存为CSV

时间:2016-11-29 16:00:46

标签: php html csv

我使用Curl从我的网站上获取数据。数据以HTML Table格式提取。那么如何正确保存CSV格式的数据

<?php
 $url = 'http://etea.edu.pk/result_controller';
 $ch = curl_init();
 $ch = curl_init($url);
 $params = [
   'search_res' => true,
   'search_value' => 108,
   'result_id'   => 272,
  ];
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
 $result = curl_exec($ch);
 curl_close($ch);

 $file = fopen("contacts.csv","w");
 fputcsv($file,explode(',',$result));
 fclose($file);
?>

0 个答案:

没有答案