Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/articles/php-tutorials/)
-   -   Google Image Leecher - Php Code (http://www.go4expert.com/articles/google-image-leecher-php-code-t10762/)

o0darkEvil0o 24May2008 02:02

Google Image Leecher - Php Code
 
This Code let you take a image search on Google easily and user-friendly.
You can pre-specify image properties: image name or caption, size and dimension rank of image.

Code Here:
PHP Code:

<?php
session_start
();
$_SESSION['count']=0;
?>
<link href="../../client/style.css" rel="stylesheet" type="text/css">
<center>
<h2>Google Image Leecher</h2>
Coder: <b>o0DarkEvil0o</b>
<form action="./" method="POST">
<table width="600">
    <tr>
        <td width="400" align="center">
            Search For
        </td>
        <td width="100" align="center">
            Max width             
        </td>
        <td width="100" align="center">
            Max height
        </td>
        <td width="100" align="center">
            Min width 
        </td>
        <td width="100" align="center">
            Min height
        </td>
    </tr>
    <tr>
        <td width="400">
            <input type="text" maxlength="40" size="40" name="res" value="<? echo $_POST['res'];?>">
        </td>
        <td width="100">
            <input type="text" maxlength="5" size="10" name="mxw" value="<? echo $_POST['mxw'];?>">
        </td>
        <td width="100">
            <input type="text" maxlength="5" size="10" name="mxh" value="<? echo $_POST['mxh'];?>">
        </td>
        <td width="100">
            <input type="text" maxlength="5" size="10" name="mnw" value="<? echo $_POST['mnw'];?>">
        </td>
        <td width="100">
            <input type="text" maxlength="5" size="10" name="mnh" value="<? echo $_POST['mnh'];?>">
        </td>
    </tr>
</table>

<input type="submit" value="Leech Now">
</form>
<hr width="600">
<table width="900">
<tr>
    <td width="700" align="center"><b>Image Link</b></td>
    <td width="100" align="left"><b>Dimesion</b></td>
    <td width="100" align="left"><b>Image Size</b></td>
</tr>

<?

ini_set('max_execution_time',0);
ini_set('time_limit',0);
ini_set('memory_limit',-1);

$linkarr=array
(
    'http://images.google.com/images?q=',
    '&imgsz=medium|large|xlarge&ndsp=20&svnum=100&hl=en&start=',
    '&sa=N'
);
$searcharr=array
(
    'dyn.Img(',
    ');dyn.updateStatus();//-->'
);
 $s2=array('<span id=maxLimit>','</span>');

function getResult($str,$hash)
{
    $p=array();
    $p[0]=strpos($str,$hash[0]);
    $p[1]=strpos($str,$hash[1],$p[0]);
    return substr($str,$p[0],$p[1]-$p[0]);
}

function CutLink($Link, $Count)
{
    if($Link=='')return 'Truy Cập trực tiếp';
    if(substr($Link,0,7)!='http://')$Link='http://'.$Link;
    $Link=str_replace('index.php','', $Link);
    $Len=strlen($Link);
    $Link1=$Link;
    if($Len>$Count)$Link1= substr($Link, 0, $Count-3).'...';
    return '<a href="'.$Link.'" target="_blank" '.$style.' onmouseover="Tip(\''.$Link.'\')">'.$Link1.'</a>';
}

function Dr_Row($link, $dimesion, $size)
{
    $str ='<tr>';
    $str.='<td align="left"><a href="'.$link.'">'.CutLink($link, 100).'</a></td>';
    $str.='<td>'.$dimesion.'</td>';
    $str.='<td>'.$size.'</td>';
    $str.='</tr>';
    return $str;
}

$searchstring=$_POST['res'];
iF($searchstring=='')die();
?>
<div align="center" id="status">Leeching <b>[<?=$searchstring;?>]</b>...</div>
<?
$searchstring=str_replace(' ','+',$searchstring);
for($k=0;$k<10000;$k++)
{
$link=$linkarr[0].$searchstring.$linkarr[1].($k*20).$linkarr[2];

$content=file_get_contents($link);
$maxres=strip_tags(getResult($content,$s2));
$maxres=str_replace(',','',$maxres);
$maxres=intval($maxres);
if($maxres/20<$k) die('<script>document.getElementById(\'status\').innerHTML=\'Done, '.$_SESSION['count'].' images is detected!\';</script>');
$arr=split('dyn.Img',getResult($content,$searcharr));
$chuoi=array();
$mxw=intval($_POST['mxw']);
$mxh=intval($_POST['mxh']);

if($mxw==0)$mxw=100000;
if($mxh==0)$mxh=100000;

$mnw=intval($_POST['mnw']);
$mnh=intval($_POST['mnh']);

foreach ($arr as $t)
{
    $chandoi=split('","',$t);
    $size=split(' - ',$chandoi[9]);
    $dimension=split(' x ',$size[0]);
    $w=intval($dimension[0]);
    $h=intval($dimension[1]);
    $sizes=intval($size[1]);
    if( ($w <= $mxw) && ($w >= $mnw) && ($h <= $mxh) && ($h >=$mnh) && ($chandoi[3]!='') )
    {
        echo Dr_Row($chandoi[3], $size[0],$size[1]);
        $_SESSION['count']++;
    }
}
}
?>
<script>
document.getElementById('status').innerHTML='Done, <? echo $_SESSION['count'].' of '.$maxres; ?> images is detected!';
</script>
</table>

</center>

Demo Here:
http://boy.us.com/Code/google/

shabbir 24May2008 08:35

Re: Google Image Leecher - Php Code
 
Its better to have the thumbnails as result display when searching for images so that I don't need to click on each of them to see it.

shabbir 2Jun2008 16:28

Re: Google Image Leecher - Php Code
 
Nomination for article of the month of May

sunadumari 2Oct2008 20:19

Re: Google Image Leecher - Php Code
 
when i copy the php to my website it doesn't work.... anyone ?

shabbir 2Oct2008 21:50

Re: Google Image Leecher - Php Code
 
Quote:

Originally Posted by sunadumari
when i copy the php to my website it doesn't work.... anyone ?

Do you mean the problem is in copying or in the code?

sunadumari 2Oct2008 23:47

Re: Google Image Leecher - Php Code
 
Quote:

Originally Posted by shabbir
Do you mean the problem is in copying or in the code?

Hi Shabbir,

I copied the php file, uploade it to the server. There I do what is needed just as with the demosite, but alas. I added some code of my own to the php file, which doesn't affect it (when I remove this it still doesn't work).

Take a look here:
http://www.ik-vind-je.nl/googleimage.php

The original inputfield is empty, the one below it contains a name. Then click on ZOEK
After this there are no results shown, merely the main page (index.php)

BR Sunadumari

code1987 16Oct2008 11:32

Re: Google Image Leecher - Php Code
 
this is nice but not workin

code1987 16Oct2008 11:34

Re: Google Image Leecher - Php Code
 
how do i use google's url in my proj for image search application

code1987 16Oct2008 11:34

Re: Google Image Leecher - Php Code
 
someone help me

code1987 16Oct2008 11:34

Re: Google Image Leecher - Php Code
 
can i fetch url from this site

code1987 16Oct2008 11:35

Re: Google Image Leecher - Php Code
 
tell me how can i fetch url from google

code1987 16Oct2008 11:37

Re: Google Image Leecher - Php Code
 
how can i fetch url from google image search

shabbir 16Oct2008 18:49

Re: Google Image Leecher - Php Code
 
code1987, Your account can get banned if you post the same thing every 2 minutes.

gkumar 3Jul2009 14:48

Re: Google Image Leecher - Php Code
 
this is nice but i want to access image url n my goggle image search application

pkphp 7Oct2010 13:35

Re: Google Image Leecher - Php Code
 
thank you very much. i like the service by google.
I can also suggest you scripts site, there are some discussion at google image. you can have a look at it.

shrikrishnatech 19Nov2010 11:34

Re: Google Image Leecher - Php Code
 
thanks for the code but how do use it? its not working


All times are GMT +5.5. The time now is 09:25.