从python加载html(页面无法正确显示内容)

时间:2020-05-08 19:09:25

标签: python html sqlite pycharm

我有下面的代码。这段代码保存在以下路径中: file:///Users/emreyavuz/PycharmProjects/untitled1/here.htm

<!DOCTYPE html>
<meta charset="utf-8">
<script src="d3.v2.js"></script>
<script src="d3.layout.cloud.js"></script>
<script src="/Users/emreyavuz/PycharmProjects/untitled1/gword.js"></script>
<body>
<script>
  var fill = d3.scale.category20();

  d3.layout.cloud().size([700, 700])
      .words(gword)
      .rotate(function() { return ~~(Math.random() * 2) * 90; })
      .font("Impact")
      .fontSize(function(d) { return d.size; })
      .on("end", draw)
      .start();

  function draw(words) {
    d3.select("body").append("svg")
        .attr("width", 700)
        .attr("height", 700)
      .append("g")
        .attr("transform", "translate(350,350)")
      .selectAll("text")
        .data(words)
      .enter().append("text")
        .style("font-size", function(d) { return d.size + "px"; })
        .style("font-family", "Impact")
        .style("fill", function(d, i) { return fill(i); })
        .attr("text-anchor", "middle")
        .attr("transform", function(d) {
          return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
        })
        .text(function(d) { return d.text; });
  }
</script>

但是,当我输入网址时: file:///Users/emreyavuz/PycharmProjects/untitled1/here.htm 进入互联网...

什么都没有出现在屏幕上。鉴于文件 gword.js 不为空,我不明白为什么会这样!

以下是 file:///Users/emreyavuz/PycharmProjects/untitled1/gword.js

的内容
gword = [{text: 'sakai', size: 100},
{text: 'with', size: 85},
{text: 'error', size: 63},
{text: 'memory', size: 56},
{text: 'sakaiportallogin', size: 41},
{text: 'presense', size: 41},
{text: 'provider', size: 41},
{text: 'lmsvle', size: 34},
{text: 'rantscomments', size: 34},
{text: 'examples', size: 34},
{text: 'problems', size: 34},
{text: 'accessing', size: 34},
{text: 'collab', size: 34},
{text: 'site', size: 34},
{text: 'internet', size: 34},
{text: 'developers', size: 27},
{text: 'austin', size: 27},
{text: 'explorer', size: 27},
{text: 'file', size: 27},
{text: 'picker', size: 27},
{text: 'nonlegacy', size: 27},
{text: 'tools', size: 27},
{text: 'worksite', size: 27},
{text: 'taxonomy', size: 27},
{text: 'call', size: 20},
{text: 'participation', size: 20},
{text: 'documentation', size: 20},
{text: 'report', size: 20},
{text: 'from', size: 20},
{text: 'conference', size: 20},
{text: 'break', size: 20},
{text: 'into', size: 20},
{text: 'song', size: 20},
{text: 'ldap', size: 20},
{text: 'authentication', size: 20},
{text: 'lone', size: 20},
{text: 'zero', size: 20},
{text: 'block', size: 20},
{text: 'logo', size: 20},
{text: 'sepp', size: 20},
{text: 'library', size: 20},
{text: 'discussion', size: 20},
{text: 'group', size: 20},
{text: 'renamed', size: 20},
{text: 'open', size: 20},
{text: 'membership', size: 20},
{text: 'code', size: 20},
{text: 'samigo', size: 20},
{text: 'conversion', size: 20},
{text: 'update', size: 20},
{text: 'audio', size: 20},
{text: 'recordings', size: 20},
{text: 'presentations', size: 20}
];

有人可以帮我吗?

0 个答案:

没有答案
相关问题