使用 Perl 或任何其他语言批量下载文件
我对 JS、HTML、CSS、C、C++ 和 C# 有很好的了解。我有一个为我们学生提供试卷的网站,但是要下载这些试卷,我们必须访问每个页面,这对我们来说太难了。大约有150个文件。所以...;)
下载链接总是这样的:
http://www.example.com/content/download_content.php?content_id=#
其中#是一个数字。
所以我想如果javascript或perl或python或任何其他语言可以下载文件并自动保存在本地。目前我不需要太多,只需要基本代码。我会学习这门语言,然后我会自己发展它。所以请各位朋友帮帮我..
I have pretty good knowledge in JS, HTML, CSS, C, C++ and C#. I have this website which offers question papers for us school students, but to download those we have to visit every page and it's too hard for us. There are about 150 files. So... ;)
The download links always look like this:
http://www.example.com/content/download_content.php?content_id=#
where # is a number.
So I thought if javascript or perl or python or any other language can download the files and save it locally automatically. Currently I don't need much, just the basic code. I'll learn the language and then I'll develop on it myself. So please help me out pals..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我通常在 bash 中执行此类操作的方式:
UPDATE 由于 URL 指向多个文件类型,因此您可以使用
file
命令来识别下载文件的类型,并相应地调整扩展名:That's how I usually do such things in bash:
UPDATE Since the URLs point to more than one file type, you could use the
file
command to identify the type of a downloaded file, and adjust the extension accordingly:这将使用 wget 程序在 shell 脚本中完成此操作,将它们全部转储到当前目录中:
This will do it in shell script using the wget program, dumping them all into the current directory:
如何使用curl代替:
应该适用于大多数Linux发行版,如果没有,您可以从这里下载curl:http:// curl.haxx.se/ 或使用“
apt-get install curl
”How about using curl instead:
Should work on most linux distros and if its not there you can download curl from here: http://curl.haxx.se/ or with a '
apt-get install curl
'