2017-10-22 19 views
1

私はこのウェブサイトからのMP4ファイルをダウンロードしようとしているが、それは私がリンクを訪問したときには禁止エラー403が示しているので、それは動作しませんを禁じ示しそして、ファイルのダウンロード:r.statusは200に等しくないが、403がどのように私はこれをバイパスすることができますので、aiohttpは、エラー403が

async with aiohttp.ClientSession() as cs: 
    async with cs.get('https://cdn-e1.streamable.com/video/mp4/kphjz.mp4') as r: 
     if r.status == 200: 
      img = await r.read() 
      with open('C:/xxxx/xxxx/xxxx/xxxx/Streamables/' + url.split('/')[-1], 'wb') as f: 
       f.write(img) 
       f.close() 
       print('Downloaded {0}'.format(url.split('/')[-1])) 

それは何もしませんか?

+0

[403](https://httpstatuses.com/403)は、あなたがそのURLにアクセスする権限がないことを意味します。 WebブラウザでこのURLを開くと、同じエラーが表示されます。そのURLにアクセスするには、おそらくHTTP認証ヘッダーが必要です。 –

答えて

1

私はそれを理解しました。私はこれを使用したはずです:

async with aiohttp.ClientSession(headers={"Referer": "https://streamable.com"}) as cs: 

必要があるheaders={"Referer": "https://streamable.com"}部分。