PHP批量下载五笔字根拆分解GIF图

180it 2020-02-27 PM 2099℃ 0条
/*
  From:憧憬点滴记忆
  Url:https://www.licoy.cn/2177.html
  PS:转载请注明出处
*/
ini_set("max_execution_time",3000); //设置时间超时为3000秒。
header("Content-type: text/html; charset=utf-8"); 
//对汉字字符串进行单个分割
function mbStrSplit($string, $len=1) {
  $start = 0;
  $strlen = mb_strlen($string);
  while ($strlen) {
  $array[] = mb_substr($string,$start,$len,"utf8");
  $string = mb_substr($string, $len, $strlen,"utf8");
  $strlen = mb_strlen($string);
  }
  return $array;
}
//开始
function start_ch($c){
  $c = iconv("utf-8","gb2312",$c);
  $url = "http://www.52wubi.com/wbbmcx/tp/{$c}.gif";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_POST, 0);
  curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  $output = curl_exec($ch);
  curl_close($ch);
  file_put_contents("./".$c.".gif",$output);
}
$chinese = file_get_contents("./chinese.txt");
$chineseArr = mbStrSplit($chinese);
foreach($chineseArr as $key => $value){
    start_ch($value);
}
echo "Download End";
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

PHP批量下载五笔字根拆分解GIF图