禁止用于非法用途,本站是否自己备份代码用:
<?php
function downloadFile($url, $path)
{
$fp = fopen($path, 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
$json = file_get_contents('1.json');
$data = json_decode($json, true);
var_dump($data);
foreach ($data['V'] as $item) {
$folderName = $item['name'];
if (!is_dir($folderName)) {
mkdir($folderName);
}
foreach ($item['videos'] as $video) {
$url = $video['videoUrl'];
$url = str_replace('http://tk.360xxx.com', 'https://s1.v.360xxx.com', $url);
$fileName = $video['videoTitle'] . '.mp4';
$saveLocalFile = $folderName . '/' . $fileName;
downloadFile($url, $saveLocalFile);
}
}上篇文章已经讲解arrayacces的原理,现在来讲解下arrayaccess的实际应用。一个大型的互联网项目中必然会存在各种配置信息,例如多种数据库信息:mysql,tidb,mongodb,redis,某个业务模块单独的配置信息如比例,额度等等,那么该如何治理配置信息?PHP项目中大部分的框架都...
php7新增的特性(1).强制限制只能返回一种类型<?php class task { } //must return an integer function add(): int { &nb...
经常我们下载国外资源容易被墙,可以通过php脚本获取远程文件流然后输出给我们的浏览器来下载。<?php //设置下载文件的url $url = 'https://mirrors.huaweicloud.com/ubuntukylin/ubuntukylin-19....
本教程使用的定时任务基于EasyTak,EasyTask官方文档:https://gitee.com/392223903/EasyTask由于tp3.2.x官方开发未考虑命令行支持和绝对路径开发的标准,因此我编写了一个支持的类来运行。1.在tp3.2.3根目录下安装easytaskcomposer&...
在调用微信code换openid的接口curl报错curl Received HTTP code 403 from proxy after CONNECT,错误码56。可以看到是curl的代理有问题。然后我自己电脑设置代理去访问curl请求的地址,的确也返回了403,说明代理不允许访问这个地址,联系...
本篇文章是给新手学习php redis队列怎么玩的。我们模拟验证码发送,通过队列完成。(1).创建一个验证码发送接口/** * 发送验证码 */ public function sendCaptcha() { ...