私はWebページからファイルをダウンロードするためのpythonを使用しています、と私はリクエストを送信した後、私は、ヘッダー、以下のように取得:pythonリクエストモジュールでウェブからデータをダウンロードする際に、ファイルをCSVに変換するには?
r.headers
{'Content-Disposition': 'attachment; filename=SABR_Download.xls',
'Content-Encoding': 'UTF-8', 'Transfer-Encoding': 'chunked', 'Expires': '0', 'Keep-Alive': 'timeout=5, max=100',
'Server': 'Apache',
'Connection': 'Keep-Alive',
'Pragma': 'no-cache',
'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Date': 'Wed, 22 Jun 2016 04:21:54 GMT',
'Content-Type': 'application/excel; charset=UTF-8'}
ここにChromeデベロッパーツールのレスポンスヘッダーがあります:
ダウンロードファイルのデフォルトの形式はExcelであるレスポンスヘッダ ソースを表示
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Disposition:attachment; filename=SABR_Download.xls
Content-Encoding:UTF-8
Content-Type:application/excel; charset=UTF-8
Date:Wed, 22 Jun 2016 04:19:53 GMT
Expires:0
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache
Transfer-Encoding:chunked
。私の質問は、Excel形式ではなくCSV形式でファイルをダウンロードする方法です。ありがとうございました。
試し 'Content-Typeの ':' テキスト/ CSV' –
@MohammadAminは、我々はレスポンスヘッダの内容を変更できますか?私はそれがサーバーの復帰だと思った、我々は要求のヘッダーの内容を変更することができます。 –