0

我有以下抓取器正在下载空文件并将它们保存到我的文件夹中。所以我有 20k 个视频文件,每个文件都是 40kb。我怎样才能得到它,所以这个脚本在表单提交之前不会 DL。

$rename = substr(md5(rand(0,9999)), 17, 10); 
$ch = curl_init("$vid");
$fp = fopen("$rename.m4v", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
$url_insert = "/dom/";
4

2 回答 2

1
if(isset($_POST['some-form-item'])){

$rename = substr(md5(rand(0,9999)), 17, 10); 
$ch = curl_init("$vid");
$fp = fopen("$rename.m4v", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
$url_insert = "/dom/";

}

仅当表单已发布其中包含某些内容时才会运行,将顶部的 if 更改为要发布的任何项目?

于 2012-06-23T22:50:48.750 回答
1
<?

if(isset($_POST["submit"])) {

$rename = substr(md5(rand(0,9999)), 17, 10); 
$ch = curl_init("$vid");
$fp = fopen("$rename.m4v", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
$url_insert = "/dom/";

}

为了使其工作,您的提交按钮的名称元素必须设置为提交。

IE:<input type="submit" name="submit" />

于 2012-06-23T22:51:59.483 回答