ruk·si

🐍 Python
Read File from Internet

Updated at 2018-11-19 20:04
pip install requests
import requests
from requests_file import FileAdapter

file_url = 'https://raw.githubusercontent.com/googlesamples/android-ndk/master/.gitignore'

with requests.session() as s:
    s.mount('file://', FileAdapter())
    resp = s.get(file_url)
    resp.raise_for_status()
    assert '.idea' in resp.text