How to download a file from jupyter-notebook with a given pop up link ? I need this pop up link and click it to download it as a HTML file. I got a problem with the character "
double quotes and '
, these character made a trouble for my HTML code in order to make it a pop up of download. But, I need these character to keep it on my script without replacing with anything.
This is my HTML script:
<html>
<head><meta charset='utf-8' /></head>
<body>
<h3>You can "view" HTML code "in" notebooks. Result 'want to' get it '"' testing only</h3>
</body>
</html>
This is my code python script:
from IPython.display import FileLink, HTML
title = "Download HTML file"
filename = "data.html"
payload = open("./cobaan_html2.html").read()
payload = payload.replace('<meta charset="utf-8" />', "<meta charset='utf-8' />")
html = '<a download="{filename}" href="data:text/html;charset=utf-8,' payload '" target="_blank">{title}</a>'
print(payload)
HTML(html)
And this is what I got.
<html>
<head><meta charset="utf-8" /></head>
<body>
<h3>You can "view" HTML code "in" notebooks. Result 'want to' get it '"' testing only</h3>
</body>
</html>
You can "view" HTML code "in" notebooks. Result 'want to' get it '"' testing only
" target="_blank">{title}
With image result prove:
CodePudding user response:
Try replacing your quotes with their non-breaking HTML equivalents as follows:
"
-->"
'
-->'