0
2

More than 3 years have passed since last update.

Python_requestでファイルをダウンロード

Posted at

今日は久しぶりにパイソンを復習しようと思います。 その中でパイソンを利用してファイルをダウンロードする方法を調べてみようと思います。

方法

方法はrequestモジュールを活用することです。

pip install requests

requestモジュールを使用するには、まずpip install requestsを使用してrequestsモジュールをインストールする必要があります。

import requests

url = "http://google.com/favicon.ico"//..... 接続したいアドレス...
req = requests.get(url, allow_redirects = True) // getを使ってもいいしpostを使ってもいいし別の接続方式を使ってもいいです
open('google.ico','wb').write(req.content)

ここからより多様な使い方を確認することができます。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2