Top
Phpuniverset logo
 
930 banner

INDHOLD

Forside

Script libary

Job annoncer

Tips og Tricks

Konkurrence

Downloads

Dokumenter

Forum

Online udviklere


ARTIKLER

CSS

Diverse

E-handel / annoncer

Grafik

Html

Internet

Javascript

Linux

PHP/MySQL

Programmer

Flash

Søgemaskiner

Windows

C / C++


INFO

Information

Annoncering

Kontakt

Forside Forum PHP, mysql søg funktion via google

søg funktion via google


 

søg funktion via google

Mikkel  

hey scriptet virker fint på nær 2 ting 
når jeg har søgt kommer der nogle hjemme sider op men de skal gerne være links og den
anden ting er vis man laver mellemrum for man error nogen der kan rette det kan ik selv
finde hvor i scriptet det er 



<?php

                



                
class Google{

                        public 
$urls;

                        public 
$count=0;



                                public function 
fetch_urls($search,$start){

                                        

                                        
// Request 100 search results from google (start
at $start), then explode on a double quote because the urls are enclosed by those.

                                        

                                       
$google="http://www.google.com/search?hl=en&q=".$search."&btnG=Google+Search&start=".$star
t
."&num=100";

                                        
$rawoutput=file_get_contents($google);

                                        
$output=explode("\"",$rawoutput);



                                        
// If the part is a url, check if it's not google
cache or other junk and add it to an array.

                

                                                foreach(
$output as $part){

                                                        if(
strpos($part'http://')===0){

                                                               
if(
strpos($part,"q=cache")==&& strpos($part,"&q=".$search)==&&
strpos($part,"google.com")==0){

                                                                       
$this->urls[]=$part;

                                                                }

                                                        }

                                                }



                                

                                }

                }



                if(
$_POST['search']){

                        

                        
$search=$_POST['search'];

                        
$Google=new Google;



                        
// Call the fetch_urls() function. 



                        
for($start=0;$start<=900;$start+=100){

                                
$Google->fetch_urls($search,$start);

                        }



                        
// If there are any results in $Google->urls, filter out the
duplicatescount them and print them.

                        
// Call flush() and ob_flush to make sure url is printed ASAP.  

                        

                        
if(!empty($Google->urls)){

                                
$Google->urls=array_unique($Google->urls);

                                
$Google->count=count($Google->urls);



                                foreach(
$Google->urls as $url){

                                        echo(
$url."<br />");

                                        
flush();

                                        
ob_flush();

                        

                                }



                        }

                        else{

                                
//No results

                        
}       

                        



                }





?>



Dato : 30.03.2008, 21:25

Visninger : 2756

Points : 150




Login for at skrive et indlg :



   Brugernavn

Password
 

+ Opret en ny Bruger, Klik her

+ Glemt brugernavn/password

 

Send Artikel/anmeldelse til: phpuni@phpuniverset.dk

Tilbage til oversigt

Phpuniverset's politik om personlige oplysninger, artikler & Koder Phpuniverset er optimeret til Mozilla 1024 * 768 Phpuniverset version: 3.0 beta
Webhost : Ignesco.dk

Bund