やりたいこと
Download Firefox without MS IEInternet Explorerを使わずにFirefoxをダウンロードする
Download Firefox from command line
コマンドラインでFIrefoxをダウンロードする
FIrefoxのアドレス
今回、ターゲットとするFirefoxのアドレスhttp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2
別のOS用 Mozilla Firefox はこちら
http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/mac/ja-JP-mac/Firefox%2019.0.dmg
http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/win32/ja/Firefox%20Setup%2019.0.exe
Google Chrome はこちら
https://dl.google.com/update2/installers/ChromeStandaloneSetup.exe
https://dl.google.com/chrome/mac/stable/GoogleChrome.dmg
https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
https://dl.google.com/linux/direct/google-chrome-stable_current_i386.rpm
https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
ファイル転送ツールを使う
wget
wget http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2
curl
curl http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2 -o firefox-19.0.tar.bz2
テキストブラウザを使う
w3m
w3m a http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2
lynx
lynx http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2
自分でプログラムを組む
perl 5.14
use LWP::Simple;
use strict;
use warnings;
my $url = "http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2";
my $filename ="firefox-19.0.tar.bz2";
my $file = get($url);
#open(OUT, ">$time.jpg");
open(OUT, ">$filename");
binmode OUT;
print OUT $file;
close(OUT);
python 3.3
from urllib import request
from urllib import parse
url = 'http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2'
filename = parse.urlparse(url)[2].split('/')[-1]
print(filename)
request.urlretrieve(url, filename)
ruby 1.9
require 'open-uri'
def save_file(url)
filename = File.basename(url)
open(filename, 'wb') do |file|
open(url) do |data|
file.write(data.read)
end
end
end
url = 'http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2'
save_file(url)
java 7
import java.net.*;
import java.io.*;
public class DownloadFile
{
public static void main(String[] args)
{
try
{
URL url = new URL("http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2");
url.openConnection();
InputStream reader = url.openStream();
FileOutputStream writer = new FileOutputStream("firefox-19.0.tar.bz2");
byte[] buffer = new byte[65535];
int bytesRead = 0;
while ((bytesRead = reader.read(buffer)) > 0)
{
writer.write(buffer, 0, bytesRead);
buffer = new byte[65535];
}
writer.close();
reader.close();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
Mono version 2.10.8.1 (C#)
using System;
using System.Net;
using System.IO;
class fileDownload
{
static void Main()
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/19.0/linux-x86_64/ja/firefox-19.0.tar.bz2");
req.UserAgent = "Mozilla/5.0 (Windows NT 6.2; rv:19.0) Gecko/20100101 Firefox/19.0";
//req.Referer = "http://www.mozilla.org";
WebResponse res = req.GetResponse();
Stream st = res.GetResponseStream();
byte[] buffer = new byte[65535];
MemoryStream ms = new MemoryStream();
while (true)
{
int rb = st.Read(buffer, 0, buffer.Length);
if (rb > 0)
{
ms.Write(buffer, 0, rb);
}
else
{
break;
}
}
FileStream fs = new FileStream("firefox-19.0.tar.bz2", FileMode.Create);
byte[] wbuf = new byte[ms.Length];
ms.Seek(0, SeekOrigin.Begin);
ms.Read(wbuf, 0, wbuf.Length);
fs.Write(wbuf, 0, wbuf.Length);
fs.Close();
}
}
追記
Windos限定 Powershellを使う
$ (New-Object Net.WebClient).DownloadFile("https://download.mozilla.org/?product=firefox-29.0&os=win&lang=ja", "Firefox Setup 29.0.exe")
0 コメント:
コメントを投稿