我从不在论坛上发帖,但我现在搜索了很多内容,但却找不到答案。
我有一个PHP登录到站点并使用cURL下载pdf文件。 这是我的代码:
<?php
require ("test_pass.php");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://rapid.deltion.nl/user/login/');
curl_setopt($ch, CURLOPT_POSTFIELDS,'username='.urlencode($login_email).'&password='.urlencode($l ogin_pass).'&login=Login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch, CURLOPT_REFERER, "https://rapid.deltion.nl/student/info/");
$page = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, 'https://rapid.deltion.nl/student/pdfresultaten/id/97041344/Luuk%20Wuijster.pdf' );
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/my_cookies.txt");
$Result = curl_exec($ch);
header('Cache-Control: public');
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="cijferlijst.pdf"');
header('Content-Length: '.strlen($Result));
echo $Result;
最终我想用cronjob每小时运行一次这段代码,并将pdf与一小时前下载的pdf进行比较。
问题是,当我转到网址时,它会将pdf下载到我自己的计算机上。 所以我试图从我的服务器运行脚本,但这也不起作用......
有人可以帮助我吗?