谷歌图片搜索 - 拇指的大小

时间:2014-04-25 16:07:24

标签: javascript php image google-image-search

我想改变我的图像搜索结果显示的thulm ..我怎么能这样做? 我的代码用于无线电自动化。搜索基于来自我的shoutcast服务器的“艺术家 - 标题”($ shoutcast_cursong_l)......

所以,每30秒,我刷新一次搜索..但是我不满意我的页面上打印的结果非常小......我希望我的结果图像宽度为250像素。

这是我的代码......我已经改变了

google.search.ImageSearch.RESTRICT_IMAGESIZE,
                                 google.search.ImageSearch.IMAGESIZE_MEDIUM 

LARGE, EXTRA_LARGE ...但这是谷歌搜索图片的地方..而不是我页面上打印的尺寸......

<?php

$server = "78.129.163.129"; // Ip du serveur
$port = "12889"; // Port du serveur
$url = "http://www.google.com/search?&q=";
$extension = ".mp3";
$listen = "listen.pls";
$date = date("d-m-Y");
$heure = date("H:i:s");
    $fp = @fsockopen($server, $port, $errno, $errstr, 30);

    if ($fp) {
        fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
        while(!feof($fp))
            $page .= fgets($fp, 1000);
        fclose($fp);
        $page = ereg_replace(".*<body>", "", $page);
        $page = ereg_replace("</body>.*", ",", $page);
        $numbers = explode(",", $page);
        $shoutcast_currentlisteners = $numbers[0];
        $connected = $numbers[1];
        if($connected == 1) {
            $radio_status = 1;
            $wordconnected = "yes";
        }
        else
            $wordconnected = "no";
        $shoutcast_peaklisteners = $numbers[2];
        $shoutcast_maxlisteners = $numbers[3];
        $shoutcast_reportedlisteners = $numbers[4];
        $shoutcast_bitrate = $numbers[5];
        $shoutcast_cursong = $numbers[6];
        $shoutcast_curbwidth = $shoutcast_bitrate * $shoutcast_currentlisteners;
        $shoutcast_peakbwidth = $shoutcast_bitrate * $shoutcast_peaklisteners;
    }
function suppr_accents($str, $encoding='windows-1252')
{
$str = htmlentities($str, ENT_NOQUOTES, $encoding);
$str = preg_replace('#&([A-za-z])(?:acute|grave|cedil|circ|orn|ring|slash|th|tilde|uml);#', '\1', $str);
$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str);
$str = preg_replace('#&[^;]+;#', '', $str);
return $str;
}
$shoutcast_cursong_l = suppr_accents($shoutcast_cursong);
?>
<html>
<head>
<title>Shoutcast infos</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="30"; url="shoutcast_infos.php">
<style type="text/css">
body {
background-color: #FFFFFF;
margin: 8px 8px 8px 8px;
text-align: left;
color: #000000;
font-family: Verdana;
font-size: 14px;
}
a:link {
color: #FF0000;
text-decoration: underline;
}
a:visited {
color: #FF0000;
text-decoration: underline;
}
a:active {
color: #FF0000;
text-decoration: underline;
}
a:hover {
color: #000000;
text-decoration: underline;
}
</style>
    <script src="//www.google.com/jsapi" type="text/javascript"></script>
    <script type="text/javascript">
    /*
    *  How to search for images and restrict them by size.
    *  This demo will also show how to use Raw Searchers, aka a searcher that is
    *  not attached to a SearchControl.  Thus, we will handle and draw the results
    *  manually.
    */

    google.load('search', '1');

    function searchComplete(searcher) {
      // Check that we got results
      if (searcher.results && searcher.results.length > 1) {
        // Grab our content div, clear it.
        var contentDiv = document.getElementById('content');
        contentDiv.innerHTML = '';

        // Loop through our results, printing them to the page.
        var results = searcher.results;
        for (var i = 3; i < results.length; i++) {
          // For each result write it's title and image to the screen
          var result = results[i];
          var imgContainer = document.createElement('p');



          var newImg = document.createElement('img');
          // There is also a result.url property which has the escaped version
          newImg.src = result.tbUrl;

          imgContainer.appendChild(newImg);

          // Put our title + image in the content
          contentDiv.appendChild(imgContainer);
        }
      }
    }
<?php
    if ($radio_status == 1) {

    echo "function OnLoad() {
      // Our ImageSearch instance.
     var imageSearch = new google.search.ImageSearch();

      // Restrict to extra large images only
      imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_IMAGESIZE,
                                 google.search.ImageSearch.IMAGESIZE_MEDIUM);

      // Here we set a callback so that anytime a search is executed, it will call
      // the searchComplete function and pass it our ImageSearch searcher.
      // When a search completes, our ImageSearch object is automatically
      // populated with the results.
      imageSearch.setSearchCompleteCallback(this, searchComplete, [imageSearch]);

      // Find me a beautiful car.
      imageSearch.execute(\"" . $shoutcast_cursong_l . "\");
    }
    google.setOnLoadCallback(OnLoad);";
    }
?>


    </script>
</head>
  <body style="font-family: Arial;border: 0 none;">
<?php
if ($radio_status == 1) {
    echo 'ON AIR ! / <a href="http://' . $server. ':' . $port . '/' . $listen . '" target="_blank" title="Ecoutez la radio en direct !">Ecouter</a><br>
    <br>
    Titre en cours : <b>' . $shoutcast_cursong_l . '</b><br>
    <a href="' . $url . '' . $shoutcast_cursong_l . '' . $extension . '" target="_blank" title="Choisissez la plateforme de téléchargement légal qui vous convient le mieux !">Rechercher</a><br>
    <br>Actuellement il y a <b>' . $shoutcast_currentlisteners . '</b> auditeurs<br>Qualité du stream : <b>' . $shoutcast_bitrate . '</b> Kbps<br>Le serveur peut accueillir : <b>' . $shoutcast_maxlisteners . '</b> auditeurs<br>Audience maximum : <b>' . $shoutcast_peaklisteners . '</b><br>
    Bande passante maximale : <b>' . $shoutcast_peakbwidth . '</b> Kbps<br>
    <br>
    <br>
    <i>'. $date .' '. $heure .'<br>
    Actualisation toutes les 30 secondes</i>
    <font color="red"><p>Pochette</font></p>
    <div id="content" style="height:500px">Loading...</div>';
}    
    else {
        echo 'OFF AIR';
}
?>

</body>
</html>

此页面上的resuklt:My Site

欢迎您的帮助。

谢谢你

0 个答案:

没有答案