图像刮取和备份问题


Issue with image scrape and backups

我的问题:

我有一个脚本,可以抓取一个网站的信息(有权限)。结果可能会导致一个空答案、一个链接或带有"N/a"的框架。

如果结果为空或N/A,我希望脚本打印到no-image.png的实习生链接。但如果我的数据库行"poster"中确实有链接,我希望显示它,而不是抓取结果。

如果刮片和我的行海报都是空的,或者我的刮片是N/A,我想显示no_image.png…

下面是代码片段。。。是的。。我知道这完全是noob写的:

if (!empty($row["poster"])){
    tr("Poster", "<object data='".$row["poster"]."height='250' width='200' align='left''title='object2' ><img src='".$image_dir."no_image.png'height='250' width='200' align='left' title='2'></object>", 1);
     }  else {
           tr("Poster", "<object data='".$row["scrape"]."'height='250' width='200' align='left' title='object1' ><img src='".$image_dir."no_image.png'height='250' width='200' align='left' title='1'></object>", 1);
}

您提到的值在$row['poster']内?

如果是这样,您可以将其与您考虑的两个值进行比较。

if ($row['poster'] === '' || $row['poster'] === 'N/A') {
    tr('Poster', '<object data="' . $row["poster"] . '" height="250" ' .
            'width="200" align="left" title="object2">' . 
            '<img src="' . $image_dir . '/no_image.png" height="250" ' . 
            'width="200" align="left" title="2"></object>', 1);
} else {
    tr('Poster', '<object data="' . $row["poster"] . '" height="250" ' .
            'width="200" align="left" title="object2">' . 
            '<img src="' . $image_dir . '/' . $row["poster"] . '" height="250" ' . 
            'width="200" align="left" title="2"></object>', 1);
}

我不知道tr函数是什么,但如果你确定你使用的是正确的格式,那么上面的代码应该这样做。您需要确保$image_dir是正确的。

也许它也像测试N/A一样简单?

 if (!empty($row["poster"]) && $row["poster"]!='N/A'){
    tr("Poster", "<object data='".$row["poster"]."'height='250' width='200' align='left''title='object2' ><img src='".$image_dir."'no_image.png' height='250' width='200' align='left' title='2'></object>", 1);
     }  else {
           tr("Poster", "<object data='".$row["scrape"]."'height='250' width='200' align='left' title='object1' ><img src='".$image_dir."no_image.png'height='250' width='200' align='left' title='1'></object>", 1);
}// JavaScript Document