Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Fint script for telefonkatalogen.no
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Scandinavian
View previous topic :: View next topic  
Author Message
samegutt
n00b
n00b


Joined: 16 Jun 2003
Posts: 26
Location: Oslo, Norway

PostPosted: Thu Aug 21, 2003 12:12 pm    Post subject: Fint script for telefonkatalogen.no Reply with quote

Hepp!!

Fant dette lure perl-scriptet som gjør oppslag i telefonkatalogen. Kan være av interesse for den noen og enhver:
http://forum.hardware.no/...osv

Ex:
Code:

localhost: ~$ tlf -f hans -l hansen -k oslo
Hansen, Hans, 0104 Oslo, 971 17 479
Hansen, Hans, Drammensveien 2, 0169 Oslo, 481 05 293
Hansen, Hans, Skovv 2 B, 0257 Oslo, 906 21 839
Hansen, Hans, Markveien 12, 0550 Oslo, 980 17 442
...osv


Code:

#!/usr/bin/perl
#
# Get info from telefonkatalogen.no
#
# Author: Thore Harald Høye
# This program is public domain
#

use LWP::Simple;

if ($ARGV[1] eq "")
{
    print "Arguments:\n-f 'fornavn' -l 'etternavn' -s 'gate' -z 'postnr' -c
'poststed' -k 'kommune' -p 'telefonnr'\n";
    exit 0;
}

while(my $arg = shift)
{
    $arg =~ s/^-//;
    $$arg = shift;
}

my $res =  get("http://www.gulesider.no/gsi/whiteSearch.do?mode=A&linje=1&sort=2&spraak=1&etter=$l&for=$f&gate=$s&pn=$z&ps=$c&kommune=$k&fylke=00&tel=$p&private=on&mobile=on&profile=on");
my @html = split(/\n/, $res);

while(@html)
{
    $_ = shift @html;
    if ($_ =~ /^<tr class="hsi"/)
    {
   my $str;
   while ($_ !~ /^<nobr>$/)
   {
       $str .= "$_ ";
       $_ = shift @html;
   }
   $str =~ s/<\/td>/,/gi;
   $str =~ s/<[^>]+>|&[a-z]+;//gi;
   $str =~ s/\s+/ /g;
   $str =~ s/\s*,[,\s]*/, /g;
   $str =~ s/^[\s,]+|[\s,]+$//g;
   print "$str\n";
    }
}





Takk til forfatter Thore Harald Høye.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Scandinavian All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum