Witam
Poniżej wkleiłem skrypt, z którym mam problem - nie wiem, którym miejscu jest błąd. Otóż wpisując adres i fraze powinny pojawić wyniki, ale się nie pojawiają. I mam problem. Może macie rozwiązanie na mój problem.
<form method="get" action="google.php" style="text-align:center;">
<input type="text" maxlength="100" name="fraza" class="contactForm1">
<input type="text" maxlength="100" name="adres" class="contactForm1">
<input type="submit" value="szukaj"/>
</form>
<?php
$sQ = $_get["fraza"];
$sPhrase = $_get["adres"];
$pozycja = new checkPosition( '$sPhrase', '$sSite' );
/*
@author Piotr `shpyo` Cichosz
<a href="http://blog.shpyo.net" target="_blank">http://blog.shpyo.net</a>
*/
class checkPosition
{
public $sLinkRegExp = '/<h3 class="r"><a href="([^"]+)" class=l>/';
public $sURL = '';
public $iLimit = 100;
'www.google.pl'
);
private $sQ = '';
private $sSite = '';
public $iPosition = '-';
public function __construct( $sPhrase, $sSite )
{
$this->sQ = $sPhrase;
$this->sSite = self::getHost( $sSite );
}
public function getHost( $sPage )
{
preg_match('@^(?:http://)?([^/]+)@i', $sPage, $matches); return $matches[1];
}
public function getPhrase()
{
return $this->sQ;
}
public function getSite()
{
return $this->sSite;
}
public function setGoogleURL( $rDC = 'www.google.pl' )
{
$this->sURL = 'http://'. $rDC .'/search?hl=pl&q=%s&num='. $this->iLimit;
}
public function getDC()
{
}
public function search( $rDC = 'www.google.pl' )
{
$rC = curl_init();
self::setGoogleURL( $rDC );
curl_setopt( $rC, CURLOPT_HEADER, 0 );
curl_setopt( $rC, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $rC, CURLOPT_VERBOSE, 1 );
curl_setopt( $rC, CURLOPT_REFERER, $rDC );
curl_setopt
( $rC, CURLOPT_URL
, sprintf( $this->sURL, urlencode( self::getPhrase() ) ) ); $sData = curl_exec( $rC );
curl_close( $rC );
$ii = 0;
for( $i=0; $i<100; $i++ )
{
$sPage = self::getHost($aResults[$i]);
if( $aResults[($i+1)] )
{
$sNext = self::getHost($aResults[($i+1)]);
if( $sDomena != $sNext )
{
$ii++;
if( $sPage == $this->sSite )
{
$this->iPosition = $ii;
break;
}
}
$sDomena = $sNext;
}
}
}
}
$pozycja->search();
echo $pozycja->iPosition;
?>