You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 KiB
13 KiB
<html>
<head>
</head>
</html>

In [1]:
# This will list all magic commands
%lsmagic
Out[1]:
Available line magics: %alias %alias_magic %autoawait %autocall %automagic %autosave %bookmark %cat %cd %clear %colors %conda %config %connect_info %cp %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %man %matplotlib %mkdir %more %mv %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode Available cell magics: %%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile Automagic is ON, % prefix IS NOT needed for line magics.
In [ ]:
Github - Download file from url¶
Tags: #github #productivity #code
Input¶
Import needed library¶
In [1]:
import uuid
import naas
import requests
Model¶
Default Github file for testing purpose¶
In [2]:
target = "https://github.com/jupyter-naas/awesome-notebooks/blob/master/Plotly/Create%20Candlestick%20chart.ipynb"
Convert url to downloadable one¶
In [3]:
# https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/Dataviz/Plotly/Create%20Candlestick%20chart.ipynb
raw_target = target.replace("https://github.com/", "https://raw.githubusercontent.com/")
raw_target = raw_target.replace("/blob/", "/")
print(raw_target)
Output¶
Dowload file locally¶
In [4]:
import urllib.parse
r = requests.get(raw_target)
uid = uuid.uuid4().hex
file_name = raw_target.split("/")[-1]
file_name = urllib.parse.unquote(file_name)
with open(file_name, "wb") as f:
f.write(r.content)