Warning: count(): Parameter must be an array or an object that implements Countable in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 820

Topic: Google Custom Search

Yra beda, niekaip nepavyksta gauti butent tik lietuvisku svetainiu is google ir "vaikscioti" per puslapius. Gal ka jus sumastysit:

<?php
function google_search_api($args, $referer = 'http://www.simep.lt', $endpoint = 'web'){
    $url = "http://ajax.googleapis.com/ajax/services/search/".$endpoint;
 
    if ( !array_key_exists('v', $args) )
        $args['v'] = '1.0';
        $args['hl'] = 'lt';
         $args['start'] = '10';
    $url .= '?'.http_build_query($args, '', '&');
 
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    $body = curl_exec($ch);
    curl_close($ch);
    return json_decode($body);
}
 
$rez = google_search_api(array(
        'q' => 'inurl:index.php?id=+',
 ));
 
print_r($rez);
?>

Nors ir nustates hll=lt bet vistiek rodo angliskus url.
Kai nustatau start=70, tarkim kad rodytu 4 resultatus gaunu:

stdClass Object
(
    [responseData] => 
    [responseDetails] => out of range start
    [responseStatus] => 400
)

Nors rezultatu kiek google rodo: Apie 29,100,000 rezult.
Niekaip nerandu tame Google API kur nustatyti kad rodytu daugiau rezultatu, bet kiek supratau tai vienu metu MAX 4 rezultatai yra, o kodel kitu puslapiu nerodo neisivaizduoju :/

Stai visas rezultatas ka gaunu:

stdClass Object
(
    [responseData] => stdClass Object
        (
            [results] => Array
                (
                    [0] => stdClass Object
                        (
                            [GsearchResultClass] => GwebSearch
                            [unescapedUrl] => http://www.pvcycle.org/index.php?id=4
                            [url]=> http://www.pvcycle.org/index.php%3Fid%3D4
                            [visibleUrl] => www.pvcycle.org
                            [cacheUrl] => http://www.google.com/search?q=cache:XEViaurU6jUJ:www.pvcycle.org
                            [title] => PV Cycle: About PV CYCLE
                            [titleNoFormatting] => PV Cycle: About PV CYCLE
                            [content] => PV CYCLE was founded in July 2007 to implement the photovoltaic industry&#39;s   commitment to set up a voluntary take back and recycling programme for <b>...</b> 
                        )
 
                    [1] => stdClass Object
                        (
                            [GsearchResultClass] => GwebSearch
                            [unescapedUrl] => http://www.ewea.org/index.php?id=180
                            [url]=> http://www.ewea.org/index.php%3Fid%3D180
                            [visibleUrl] => www.ewea.org
                            [cacheUrl] => http://www.google.com/search?q=cache:OoGotXQ0nagJ:www.ewea.org
                            [title] => European Wind Energy Association - EWEA: European Statistics
                            [titleNoFormatting] => European Wind Energy Association - EWEA: European Statistics
                            [content] => EWEA - European Wind Energy Association - The most powerful wind energy network.
                        )
 
                    [2] => stdClass Object
                        (
                            [GsearchResultClass] => GwebSearch
                            [unescapedUrl] => http://www.gestiondesarts.com/index.php?id=720
                            [url]=> http://www.gestiondesarts.com/index.php%3Fid%3D720
                            [visibleUrl] => www.gestiondesarts.com
                            [cacheUrl] => http://www.google.com/search?q=cache:8wmx1guoKpwJ:www.gestiondesarts.com
                            [title] => INTERNATIONAL JOURNAL OF ARTS MANAGEMENT (IJAM)
                            [titleNoFormatting] => INTERNATIONAL JOURNAL OF ARTS MANAGEMENT (IJAM)
                            [content] => CURRENT ISSUE Volume 13 - no 1. FALL 2010. Table of contents. Published for the   first time in the fall of 1998, the International Journal of Arts Management <b>...</b> 
                        )
 
                    [3] => stdClass Object
                        (
                            [GsearchResultClass] => GwebSearch
                            [unescapedUrl] => http://www.firebirdsql.org/index.php?id=about-firebird&nosb=1
                            [url]=> http://www.firebirdsql.org/index.php%3Fid%3Dabout-firebird%26nosb%3D1
                            [visibleUrl] => www.firebirdsql.org
                            [cacheUrl] => http://www.google.com/search?q=cache:n3-AwuT89N4J:www.firebirdsql.org
                            [title] => Firebird - The RDBMS that&#39;s going where you&#39;re going
                            [titleNoFormatting] => Firebird - The RDBMS that&#39;s going where you&#39;re going
                            [content] => Firebird is a relational database offering many ANSI SQL-92 features that runs   on Linux, Windows, and a variety of Unix platforms.
                        )
 
                )
 
            [cursor] => stdClass Object
                (
                    [pages] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [start] => 0
                                    [label] => 1
                                )
 
                            [1] => stdClass Object
                                (
                                    [start] => 4
                                    [label] => 2
                                )
 
                            [2] => stdClass Object
                                (
                                    [start] => 8
                                    [label] => 3
                                )
 
                            [3] => stdClass Object
                                (
                                    [start] => 12
                                    [label] => 4
                                )
 
                            [4] => stdClass Object
                                (
                                    [start] => 16
                                    [label] => 5
                                )
 
                            [5] => stdClass Object
                                (
                                    [start] => 20
                                    [label] => 6
                                )
 
                            [6] => stdClass Object
                                (
                                    [start] => 24
                                    [label] => 7
                                )
 
                            [7] => stdClass Object
                                (
                                    [start] => 28
                                    [label] => 8
                                )
 
                        )
 
                    [estimatedResultCount] => 9850000
                    [currentPageIndex] => 2
                    [moreResultsUrl] => http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=10&hl=lt&q=inurl:index.php?id%3D%2B
                )
 
        )
 
    [responseDetails] => 
    [responseStatus] => 200
)

Re: Google Custom Search

Dėl lietuviškų resultatų pridėk į query "site:.lt" (-;

Arba reikia pasiskaityti ar galima nauti parametrą: cr=countryLT

Re: Google Custom Search

Jau isbandziau, nelabai reaguoja :)

Re: Google Custom Search

Gali bandyti su curl žaisti ir rezultatus imti iš google.lt ne .com. Kažkada veikė.
Arba lr=lang_lt (kalbai) arba cr=countryLT (regionui)