Pogledajte određenu poruku
Staro 17. 06. 2011.   #5
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

Ja sam parsirao onda samo ove za koje imaju planovi leta u njihovoj bazi podataka.
Odlično je što imaju i koordinate.

PHP kôd:
if($action == "parse.code"){
    
$html file_get_html("http://timetables.oag.com/BNX/LetterSearch.asp?letter=$q");
    
$i 0;
    foreach(
$html->find("table[cellspacing=1] tr") as $tr){
        
$a $tr->find("td a"0)->href;
        
preg_match("#\('(.*?)', '(.*?)'\)#"$a$matches);
        unset(
$matches[0]);
        
$city $matches[1];
        
$code $matches[2];
        
$country $tr->find("td"2)->plaintext;
        
        
$city addslashes($city);
        
$country addslashes($country);
        
        echo(
"INSERT INTO airports(code,city,country) VALUES('$code','$city','$country');<br />");
        
$i++;
    }


Ovaj world-airport-codes.com je malo komplikovaniji pa nisam htio da petljam ali evo i za njega...

PHP kôd:
if($action == "parse.codes"){

    
$html file_get_html("http://www.world-airport-codes.com/search/?criteria=$q");
    foreach(
$html->find("table.results tr") as $tr){
        
$rows[] = $tr->plaintext;   
    }
    unset(
$rows[0]);
    
$count count($rows);
    for(
$i 1$i <= $count$i++){
        if(
$i == 0$results[] = $rows[$i];
    }
    foreach(
$results as $key => $value){
        
$value str_replace(array("\t""\n"), ";"$value);
        
$value preg_replace("#(;){1,}#is"";"$value);
        
$results[$key] = trim($value";");
    }
    
print_r($results);
    


Poslednja izmena od webarto : 17. 06. 2011. u 14:21.
webarto je offline   Odgovorite uz citat
"Hvala" webarto za poruku: