- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含 Bokeh 图的完整 html 文件。现在我正在尝试使用 python 电子邮件模块发送该 html。我只是使用此处给出的第三个示例:https://docs.python.org/2.7/library/email-examples.html (如何创建 HTML 消息......)
但这似乎只是向我发送了一封空白电子邮件。
我还尝试了其他一些包含嵌入式 javascript 的 html。这似乎很好(禁用 JS,我不关心)。
关于可能发生的事情以及我可以改变什么的任何线索?
这是 html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bokeh Scatter Plots</title>
<link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-0.9.0.min.css" type="text/css" />
<script type="text/javascript" src="http://cdn.bokeh.org/bokeh/release/bokeh-0.9.0.min.js"></script>
<script type="text/javascript">
Bokeh.$(function() {
var all_models = [{"attributes": {"line_color": {"value": "white"}, "fill_color": {"value": "#5ab738"}, "tags": [], "doc": null, "fill_alpha": {"value": 0.7}, "height": {"units": "data", "field": "z"}, "width": {"units": "data", "field": "width_cat"}, "y": {"field": "midz"}, "x": {"field": "catz"}, "id": "20b3f29b-629c-4d0d-a8ef-9bc05e5b178a"}, "type": "Rect", "id": "20b3f29b-629c-4d0d-a8ef-9bc05e5b178a"}, {"attributes": {"nonselection_glyph": null, "data_source": {"type": "ColumnDataSource", "id": "23913a89-b55a-4191-a5c3-3195acc7e1f4"}, "tags": [], "doc": null, "selection_glyph": null, "id": "5eda121f-edca-48cf-aed6-1e109b54b2ff", "glyph": {"type": "Rect", "id": "20b3f29b-629c-4d0d-a8ef-9bc05e5b178a"}}, "type": "GlyphRenderer", "id": "5eda121f-edca-48cf-aed6-1e109b54b2ff"}, {"attributes": {"geometries": [], "tags": [], "doc": null, "id": "c43afbcc-a846-4f33-a482-039a0fd206e8"}, "type": "ToolEvents", "id": "c43afbcc-a846-4f33-a482-039a0fd206e8"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "tags": [], "doc": null, "major_label_orientation": 0.7853981633974483, "axis_label": "categories", "formatter": {"type": "CategoricalTickFormatter", "id": "f27df891-c727-4511-af15-049332957dda"}, "ticker": {"type": "CategoricalTicker", "id": "9d14f049-833c-4895-bb18-a13fd30163a3"}, "id": "50005101-7498-4430-8b3e-fece52250277"}, "type": "CategoricalAxis", "id": "50005101-7498-4430-8b3e-fece52250277"}, {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b", "attributes": {"x_range": {"type": "FactorRange", "id": "46a7ffcd-19f4-4d8a-ae50-e01aa946b82e"}, "right": [], "above": [], "tags": [], "tools": [{"type": "PanTool", "id": "d6948ffa-b6f5-4379-a967-82dca90488a0"}, {"type": "WheelZoomTool", "id": "03df0ff2-3de4-4341-aecc-1bc593ebb8f2"}, {"type": "BoxZoomTool", "id": "3b6ab084-b09a-4131-809e-282113f78357"}, {"type": "PreviewSaveTool", "id": "8264e0e1-e9b3-44cd-aed7-02d01251240a"}, {"type": "ResizeTool", "id": "d3c48641-01cb-467c-91ee-3a0c6085d201"}, {"type": "ResetTool", "id": "3f0c4f54-5e2b-4253-b7e4-9bb9a7deabab"}, {"type": "HelpTool", "id": "3a1fb46c-8124-4374-83a4-2dd5bf4f6860"}], "title": "Bar example p", "renderers": [{"type": "CategoricalAxis", "id": "50005101-7498-4430-8b3e-fece52250277"}, {"type": "LinearAxis", "id": "42be7469-495b-4e8a-8021-a9a3191cecf0"}, {"type": "Grid", "id": "42bb2980-8afe-426d-9894-767dd3e4caad"}, {"type": "GlyphRenderer", "id": "8eb8810b-0e44-4851-89df-79debf7dbe2a"}, {"type": "GlyphRenderer", "id": "5eda121f-edca-48cf-aed6-1e109b54b2ff"}], "plot_width": 400, "extra_y_ranges": {}, "extra_x_ranges": {}, "tool_events": {"type": "ToolEvents", "id": "c43afbcc-a846-4f33-a482-039a0fd206e8"}, "plot_height": 400, "doc": null, "id": "36f2771e-837b-4b64-b541-523ef126784b", "y_range": {"type": "Range1d", "id": "90174572-530c-4de3-8906-e80952108b06"}, "below": [{"type": "CategoricalAxis", "id": "50005101-7498-4430-8b3e-fece52250277"}], "left": [{"type": "LinearAxis", "id": "42be7469-495b-4e8a-8021-a9a3191cecf0"}]}}, {"attributes": {"doc": null, "id": "9d14f049-833c-4895-bb18-a13fd30163a3", "tags": []}, "type": "CategoricalTicker", "id": "9d14f049-833c-4895-bb18-a13fd30163a3"}, {"attributes": {"doc": null, "id": "f27df891-c727-4511-af15-049332957dda", "tags": []}, "type": "CategoricalTickFormatter", "id": "f27df891-c727-4511-af15-049332957dda"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "tags": [], "doc": null, "axis_label": "values", "formatter": {"type": "BasicTickFormatter", "id": "a5efb989-af95-4129-983a-b867fe96eddf"}, "ticker": {"type": "BasicTicker", "id": "57a0ff59-725c-4d01-920a-2a3f8c65e6c4"}, "id": "42be7469-495b-4e8a-8021-a9a3191cecf0"}, "type": "LinearAxis", "id": "42be7469-495b-4e8a-8021-a9a3191cecf0"}, {"attributes": {"tags": [], "doc": null, "mantissas": [2, 5, 10], "id": "57a0ff59-725c-4d01-920a-2a3f8c65e6c4"}, "type": "BasicTicker", "id": "57a0ff59-725c-4d01-920a-2a3f8c65e6c4"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "tags": [], "doc": null, "dimension": 1, "ticker": {"type": "BasicTicker", "id": "57a0ff59-725c-4d01-920a-2a3f8c65e6c4"}, "id": "42bb2980-8afe-426d-9894-767dd3e4caad"}, "type": "Grid", "id": "42bb2980-8afe-426d-9894-767dd3e4caad"}, {"attributes": {"doc": null, "id": "a5efb989-af95-4129-983a-b867fe96eddf", "tags": []}, "type": "BasicTickFormatter", "id": "a5efb989-af95-4129-983a-b867fe96eddf"}, {"attributes": {"column_names": ["width_cat", "stackedz", "stackedy", "cat", "width", "zero", "midz", "midy", "y", "caty", "catz", "z"], "tags": [], "doc": null, "selected": {"2d": {"indices": []}, "1d": {"indices": []}, "0d": {"indices": [], "flag": false}}, "callback": null, "data": {"width_cat": [0.2, 0.2, 0.2, 0.2, 0.2], "stackedz": [6.5, 9.5, 8.0, 6.0, 6.0], "stackedy": [3.0, 3.5, 1.0, 2.0, 2.5], "cat": ["C1", "C2", "C3", "D1", "D2"], "width": [0.8, 0.8, 0.8, 0.8, 0.8], "zero": [7.0, 12.0, 14.0, 8.0, 7.0], "midz": [0.5, 2.5, 6.0, 2.0, 1.0], "midy": [3.0, 3.5, 1.0, 2.0, 2.5], "y": [6, 7, 2, 4, 5], "caty": ["C1:0.333333333333", "C2:0.333333333333", "C3:0.333333333333", "D1:0.333333333333", "D2:0.333333333333"], "catz": ["C1:0.666666666667", "C2:0.666666666667", "C3:0.666666666667", "D1:0.666666666667", "D2:0.666666666667"], "z": [1, 5, 12, 4, 2]}, "id": "23913a89-b55a-4191-a5c3-3195acc7e1f4"}, "type": "ColumnDataSource", "id": "23913a89-b55a-4191-a5c3-3195acc7e1f4"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "d6948ffa-b6f5-4379-a967-82dca90488a0"}, "type": "PanTool", "id": "d6948ffa-b6f5-4379-a967-82dca90488a0"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "03df0ff2-3de4-4341-aecc-1bc593ebb8f2"}, "type": "WheelZoomTool", "id": "03df0ff2-3de4-4341-aecc-1bc593ebb8f2"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "3b6ab084-b09a-4131-809e-282113f78357"}, "type": "BoxZoomTool", "id": "3b6ab084-b09a-4131-809e-282113f78357"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "tags": [], "doc": null, "id": "8264e0e1-e9b3-44cd-aed7-02d01251240a"}, "type": "PreviewSaveTool", "id": "8264e0e1-e9b3-44cd-aed7-02d01251240a"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "tags": [], "doc": null, "id": "d3c48641-01cb-467c-91ee-3a0c6085d201"}, "type": "ResizeTool", "id": "d3c48641-01cb-467c-91ee-3a0c6085d201"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "tags": [], "doc": null, "id": "3f0c4f54-5e2b-4253-b7e4-9bb9a7deabab"}, "type": "ResetTool", "id": "3f0c4f54-5e2b-4253-b7e4-9bb9a7deabab"}, {"attributes": {"plot": {"subtype": "Chart", "type": "Plot", "id": "36f2771e-837b-4b64-b541-523ef126784b"}, "tags": [], "doc": null, "id": "3a1fb46c-8124-4374-83a4-2dd5bf4f6860"}, "type": "HelpTool", "id": "3a1fb46c-8124-4374-83a4-2dd5bf4f6860"}, {"attributes": {"callback": null, "factors": ["C1", "C2", "C3", "D1", "D2"], "doc": null, "tags": [], "id": "46a7ffcd-19f4-4d8a-ae50-e01aa946b82e"}, "type": "FactorRange", "id": "46a7ffcd-19f4-4d8a-ae50-e01aa946b82e"}, {"attributes": {"end": 13.200000000000001, "callback": null, "doc": null, "tags": [], "start": 0, "id": "90174572-530c-4de3-8906-e80952108b06"}, "type": "Range1d", "id": "90174572-530c-4de3-8906-e80952108b06"}, {"attributes": {"line_color": {"value": "white"}, "fill_color": {"value": "#f22c40"}, "tags": [], "doc": null, "fill_alpha": {"value": 0.7}, "height": {"units": "data", "field": "y"}, "width": {"units": "data", "field": "width_cat"}, "y": {"field": "midy"}, "x": {"field": "caty"}, "id": "43271b33-7e9c-4120-a177-4d0f1c233de1"}, "type": "Rect", "id": "43271b33-7e9c-4120-a177-4d0f1c233de1"}, {"attributes": {"nonselection_glyph": null, "data_source": {"type": "ColumnDataSource", "id": "23913a89-b55a-4191-a5c3-3195acc7e1f4"}, "tags": [], "doc": null, "selection_glyph": null, "id": "8eb8810b-0e44-4851-89df-79debf7dbe2a", "glyph": {"type": "Rect", "id": "43271b33-7e9c-4120-a177-4d0f1c233de1"}}, "type": "GlyphRenderer", "id": "8eb8810b-0e44-4851-89df-79debf7dbe2a"}];
Bokeh.load_models(all_models);
var plots = [{'modeltype': 'Plot', 'elementid': '#806c01c5-0a0d-4d12-9df9-5de64399e878', 'modelid': '36f2771e-837b-4b64-b541-523ef126784b'}];
for (idx in plots) {
var plot = plots[idx];
var model = Bokeh.Collections(plot.modeltype).get(plot.modelid);
Bokeh.logger.info('Realizing plot:')
Bokeh.logger.info(' - modeltype: ' + plot.modeltype);
Bokeh.logger.info(' - modelid: ' + plot.modelid);
Bokeh.logger.info(' - elementid: ' + plot.elementid);
var view = new model.default_view({
model: model,
el: plot.elementid
});
Bokeh.index[plot.modelid] = view;
}
});
</script>
</head>
<body>
<div class="plotdiv" id="806c01c5-0a0d-4d12-9df9-5de64399e878"></div> </body>
</html>
这是 python 脚本:
#!/usr/bin/env python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
me = 'abc@mac.com'
you = 'abc@abc.com'
# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link JavaScript big"
msg['From'] = me
msg['To'] = you
# Create the body of the message (a plain-text and an HTML version).
#text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttps://www.python.org"
# example below
'''
html = """\
<!DOCTYPE html>
<html>
<body>
<h1>My First JavaScript</h1>
<button type="button"
onclick="document.getElementById('demo').innerHTML = Date()">
Click me to display Date and Time.</button>
<p id="demo"></p>
</body>
</html>
"""
'''
# html goes here
html = """\
"""
# Record the MIME types of both parts - text/plain and text/html.
#part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
#msg.attach(part1)
msg.attach(part2)
# Send the message via local SMTP server.
s = smtplib.SMTP('localhost')
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(me, you, msg.as_string())
s.quit()
bokeh html 包含在注释“# html goes here”下方的三重引号中(就像上面的示例一样)
最佳答案
如评论中所述,电子邮件不呈现 HTML。
我想到了三个选项:将绘图转换为图像并发送,将绘图放到服务器并将指向绘图的链接放入电子邮件或将 HTML 作为附件发送。我认为您可能无法单独在 HTML 主体上按原样显示情节。
将情节作为附件的一种简单方法是通过 Red Mail 进行:
from redmail import EmailSender
email = EmailSender(
host="smtp.myserver.com", port=587,
username="me@example.com", password="<PASSWORD>"
)
plot_content = "<!DOCTYPE html><html lang="en">....</html>"
msg = email.send(
sender=["me@example.com"],
receivers=["you@example.com"],
subject="Link JavaScript big",
text="The plot is attached.",
attachments={'plot.html': plot_content},
)
如果您喜欢这种方式,它还支持将图像嵌入到 HTML 正文中。它还是高度可定制的并且功能非常丰富,因此很可能足以满足您的用例。
Red Mail 的文档:https://red-mail.readthedocs.io
免责声明:我是作者,请按您认为合适的方式使用它。
关于javascript - 使用 python 电子邮件或其他模块在电子邮件中发送 Bokeh 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31555116/
我有一个 html 格式的表单: 我需要得到 JavaScript在value input 字段执行,但只能通过表单的 submit .原因是页面是一个模板所以我不控制它(不能有
我管理的论坛是托管软件,因此我无法访问源代码,我只能向页面添加 JavaScript 来实现我需要完成的任务。 我正在尝试用超链接替换所有页面上某些文本关键字的第一个实例。我还根据国家/地区代码对这些
我正在使用 JS 打开新页面并将 HTML 代码写入其中,但是当我尝试使用 document.write() 在新页面中编写 JS 时功能不起作用。显然,一旦看到 ,主 JS 就会关闭。用于即将打开的
提问不是为了解决问题,提问是为了更好地理解系统 专家!我知道每当你将 javascript 代码输入 javascript 引擎时,它会立即由 javascript 引擎执行。由于没有看过Engi
我在一个文件夹中有两个 javascript 文件。我想将一个变量的 javascript 文件传递到另一个。我应该使用什么程序? 最佳答案 window.postMessage用于跨文档消息。使
我有一个练习,我需要输入两个输入并检查它们是否都等于一个。 如果是 console.log 正则 console.log false 我试过这样的事情: function isPositive(fir
我正在做一个Web应用程序,计划允许其他网站(客户端)在其页面上嵌入以下javascript: 我的网络应用程序位于 http://example.org 。 我不能假设客户端网站的页面有 JQue
目前我正在使用三个外部 JS 文件。 我喜欢将所有三个 JS 文件合而为一。 尽一切可能。我创建 aio.js 并在 aio.js 中 src="https://code.jquery.com/
我有例如像这样的数组: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = {
所以我正在制作一个 Chrome 扩展,它使用我制作的一些 TamperMonkey 脚本。我想要一个“主”javascript 文件,您可以在其中包含并执行其他脚本。我很擅长使用以下行将其他 jav
我有 A、B html 和 A、B javascript 文件。 并且,如何将 A JavaScript 中使用的全局变量直接移动到 B JavaScript 中? 示例 JavaScript) va
我需要将以下整个代码放入名为 activate.js 的 JavaScript 中。你能告诉我怎么做吗? var int = new int({ seconds: 30, mark
我已经为我的 .net Web 应用程序创建了母版页 EXAMPLE1.Master。他们的 I 将值存储在 JavaScript 变量中。我想在另一个 JS 文件中检索该变量。 示例1.大师:-
是否有任何库可以用来转换这样的代码: function () { var a = 1; } 像这样的代码: function () { var a = 1; } 在我的浏览器中。因为我在 Gi
我收到语法缺失 ) 错误 $(document).ready(function changeText() { var p = document.getElementById('bidp
我正在制作进度条。它有一个标签。我想调整某个脚本完成的标签。在找到可能的解决方案的一些答案后,我想出了以下脚本。第一个启动并按预期工作。然而,第二个却没有。它出什么问题了?代码如下: HTML:
这里有一个很简单的问题,我简单的头脑无法回答:为什么我在外部库中加载时,下面的匿名和onload函数没有运行?我错过了一些非常非常基本的东西。 Library.js 只有一行:console.log(
我知道 javascript 是一种客户端语言,但如果实际代码中嵌入的 javascript 代码以某种方式与在控制台上运行的代码不同,我会尝试找到答案。让我用一个例子来解释它: 我想创建一个像 Mi
我如何将这个内联 javascript 更改为 Unobtrusive JavaScript? 谢谢! 感谢您的回答,但它不起作用。我的代码是: PHP js文件 document.getElem
我正在寻找将简单的 JavaScript 对象“转储”到动态生成的 JavaScript 源代码中的最优雅的方法。 目的:假设我们有 node.js 服务器生成 HTML。我们在服务器端有一个对象x。
我是一名优秀的程序员,十分优秀!