[*-CA] Re: CID Lookup
Nabeel Jafferali
asterisk-lists at x2n.ca
Sat May 7 17:42:13 EDT 2005
BTW This does not do most business name lookups from 411.com correctly.
Maybe someone who actually knows Perl can do that :)
--
Nabeel Jafferali
X2 Networks
www.x2n.ca
T: 1.647.722.6900
1.877.VOIP.X2N
F: 1.866.655.6698
FWD: 46990
> -----Original Message-----
> From: Nabeel Jafferali [mailto:asterisk-lists at x2n.ca]
> Sent: May 7, 2005 5:36 PM
> To: asterisk at uc.org
> Cc: asterisk-canada at lists.syonex.com
> Subject: [on-asterisk] CID Lookup
>
> Jim Meehan had posted something to asterisk-users a couple of months ago
> that looked up CID info from Google and, failing that, got the NPA/NXX
> info
> from areacodedownload.com. I modified his script to look up Google, then
> look up 411.com, since the latter has Canadian listings. I left Google in
> because it's significantly faster. I removed the reversing first/last
> names
> and the NPA/NXX lookup. Here the code, if anyone is interested:
>
>
> #!/usr/bin/perl
> use Asterisk::AGI;
> $AGI = new Asterisk::AGI;
> $number = $ARGV[0];
> $found = 0;
>
> open(RESULTS, "/usr/bin/curl -s -m 2 -A Mozilla/4.0
> http://www.google.com/search?q=phonebook:$number |");
> while (<RESULTS>) {
> if (m/Residential Phonebook/ || m/Business Phonebook/) {
> $found = 1;
> @fields = split(/>/);
> @result = split(/-/, $fields[35]);
> chop($result[0]);
> $name = $result[0];
> }
> if (m/did not match any/) {
> $found = 0;
> }
> }
>
> if ($found == 0) {
> open(RESULTS, "/usr/bin/curl -s -m 2 -A Mozilla/4.0
> http://www.411.com/10668/search/Reverse_Phone?phone=$number |");
> while (<RESULTS>) {
> if (m/__FIRST/) {
> $found = 1;
> @fname = split(/\"/);
> }
> elsif (m/__LAST/) {
> @lname = split(/\"/);
> $name = $fname[1] . " " .$lname[1];
> }
> }
> }
>
> $AGI->set_variable('googlename', "\"$name\"");
>
> --
> Nabeel Jafferali
> X2 Networks
> www.x2n.ca
> T: 1.647.722.6900
> 1.877.VOIP.X2N
> F: 1.866.655.6698
> FWD: 46990
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: asterisk-unsubscribe at uc.org
> For additional commands, e-mail: asterisk-help at uc.org
>
More information about the Asterisk-Canada
mailing list