などとやろうものなら、華麗にAttributeError: module 'requests' has no attribute 'propfind'と返してくれます。 代わりに、Requestsの低レベルAPIであるRequestとSessionを用いて、PROPFINDメソッドを投げてみましょう。 import requests def propfind(url): req = requests.Request('PROPFIND', url, headers={'Depth': '1'}) prepped = req.prepare() s = requests.Session() resp = s.send(prepped) return resp.text headers={'Depth': '1'}としているのは、WebDAV内の全リストを取得するとサーバ側に負荷が掛かる為、指
{ 'fileName': 'ファイル名', 'contentType': 'mimetype', 'contentData': 'バイナリデータをbase64でエンコードしたascii文字列' } 1.3. 普通のファイルダウンロード HTTPレスポンスヘッダにファイルのコンテントタイプやファイル名を設定し、HTTPレスポンスボディにファイルのデータを設定する普通のファイルダウンロードの方法です。 こちらもHTTPの仕様に準拠しているため、クライアント(requests)およびサーバ(Flask)にファイルダウンロードを考慮した便利なAPIが用意されています。 2. 応用 2.1. Flaskで巨大ファイルのダウンロードを実現する方法(予定) データサイズが数百MBから数GBのファイルをダウンロードさせる場合、サーバのリソース(主にメモリ)を考慮した実装を行う必要があります。 バッファリ
Requests: 人間のためのHTTP¶ リリース v1.0.4. (Installation) Requestsは、人が使いやすいように設計されていて、Pythonで書かれている Apache2 Licensed ベースのHTTPライブラリです。 Pythonの標準の urllib2 モジュールは、必要とされるほとんどのHTTPの機能を備えていますが、APIがまともに 使えません 。 様々なウェブ用途に合わせて作られていて、何回も修正されてきました。 簡単なことを行う(メソッドの上書きでさえ)のに、 かなり の量の作業が必要になります。 それはPython的ではないので、そんなに複雑にするべきではありません。 >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass')) >>> r.status_c
みんなのIoT/みんなのPythonの著者。二子玉近く160平米の庭付き一戸建てに嫁/息子/娘/わんこと暮らしてます。月間1000万PV/150万UUのWebサービス運営中。 免責事項 プライバシーポリシー Pythonには「後方互換性を大切にする」というモットーがあって,時にはそれが裏目に出ることがある。PythonでWebにリクエストを送る時の手法は,目的に応じて複数存在するが,これも後方互換性を守るがために起こっている現象といえる。当初はシンプルな機能を持つモジュールが利用されていて,その後より高度な機能を持つモジュールが追加されたのだが,後方互換性を守るために古いモジュールが残されているのだ。 たとえば,普通にhtppでGETリクエストを送って結果を取得するなら簡単で from urllib import urlopen src = urlopen('http://www.exam
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く