0

我一直在尝试使用websnapr服务在悬停时为每个网站 URL 创建流畅的图像预览。下面的 javascript 效果很好,但是会动态生成网站预览,这很慢,而且似乎没有必要,因为我总是使用相同的数据库条目,并且这种方法可能会多次生成相同网站的图像预览(在每次刷新),实际上只要一次就足够了,只要我有并且可以将图像路径存储在数据库中以供以后使用。

我正在使用的数据库包含 3,000 多个网站 URL。我想使用 PHP 脚本并通过将websnapr图像路径存储在数据库中以自动方式为每一个创建缩略图预览,以便以后可以使用它们以更有效的方式生成网站预览。但是,这有点超出我的水平......

我很感激任何建议如何做到这一点。

提前谢谢了!

JavaScript

$('.co-website').each(function(){
    var url = encodeURIComponent($(this).children('a').attr('href'));

    var imgSRC = 'http://images.websnapr.com/?url=' + url + '&key=' + apiKey + '&hash=' + encodeURIComponent(websnapr_hash);
    $(this).children('a').attr("title", "<img src='"+imgSRC+"' />");
});

PHP 脚本

while($row = mysqli_fetch_array($results)){
    $thumbnail_url = 'http://images.websnapr.com/?url=' . $row['website'] . '&key='.$apiKey.'&hash='.; 
    //Not sure how to get the hash portion of the URL
}
//update this record's thumbnail mySQL field
4

0 回答 0