试图在隐藏的下载URL上查找文件扩展名

时间:2016-06-09 18:44:24

标签: php url hidden

我正在尝试制作一个脚本来获取可下载的文件并将其放到我的ftp服务器上然后更新数据库。我无法弄清楚url扩展应该是什么才能使这项工作。

<?php
$src = fopen('https://www.atf.gov/firearms/docs/0516-ffl-listxlsx/download', 'r');
$dest1 = fopen('first1k.xlsx', 'w');
$dest2 = fopen('remainder.xlsx', 'w');

echo stream_copy_to_stream($src, $dest1, 19759460) . " bytes copied to first1k.txt\n";
echo stream_copy_to_stream($src, $dest2) . " bytes copied to remainder.txt\n";

?>

这是我尝试从https://www.atf.gov/firearms/listing-federal-firearms-licensees-ffls-2016

获取数据的地方

1 个答案:

答案 0 :(得分:0)

    <?php
$file = "0516.xlsx";
$url = 'https://www.atf.gov/firearms/docs/0516-ffl-listxlsx/download' ;

$handle = fopen("0516.xlsx", "w+");
fwrite($handle, file_get_contents($url));
rewind($handle);

$read = htmlentities(fread($handle, filesize($file)));

?>

修好了

相关问题