如何在 html 中获取网页 link 的小缩略图

How to get a small thumbnail of a webpage link inside html

我打算在我的 Gatsby 网页上显示其他人的博客列表 post 作为 link。我不想在 html 中添加图像和标题,而是想从博客 post/web 页面中提取信息。就像 WhatsApp 如何在附加的快照中获得一个小缩略图一样: 我是否必须从页面中提取信息,或者是否有图书馆可以为我做这件事?

如果您拥有这些网站,则可以允许 X-Frame-Options: ALLOW-FROM [uri]。如果您不这样做,大多数网站将无法运行。

否则,您将必须截屏并保留图像,可以手动进行,也可以使用预定过程进行。

$(document).ready(function() {
  var mouseX;
  var mouseY;
  $(document).mousemove( function(e) {
     mouseX = e.pageX; 
     mouseY = e.pageY;
  });  

  $('a').mouseover(function() {
    console.log('mouse over <a />');
    console.log(this.href);
    $('#previewFrame').attr('src', this.href);
    $('#frameContainer').css({'top':mouseY+20,'left':mouseX+20});
    $('#frameContainer').show();
  });
  
    $('a').mouseout(function() {
    console.log('mouse out of <a />');
    $('#frameContainer').hide();
  });
});
#frameContainer {
    display:none; position: absolute;
    background-color: #ffffff;
    height:1000px;
    width:1000px;
    overflow: hidden;
}

#previewFrame {
  transform-origin: left top;
  -webkit-transform:scale(0.2);
  -moz-transform-scale(0.2);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="https://www.bbc.com">BBC</a> - Works<br/>
<div>Other texts and page content....................<div>
<div>Other texts and page content....................<div>
<div>Other texts and page content....................<div>
<a href="https://www.cnn.com/">CNN</a> - Won't work<br/>
<div>Other texts and page content....................<div>
<div>Other texts and page content....................<div>
<div>Other texts and page content....................<div>
<div>Other texts and page content....................<div>
<a href="https://whosebug.com/">Whosebug</a> - Won't work<br/>
<div>Other texts and page content....................<div>
<div>Other texts and page content....................<div>
<div id='divtest' style='display:none; position: absolute;'>This is a test</div>
<div id="frameContainer">
  <iframe id='previewFrame' width="500" height="500" src="" style="">
  </iframe>
 </div>