/[corp]/esi/filter.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /esi/filter.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Thu Mar 15 07:51:21 2001 UTC (23 years, 1 month ago) by dpavlin
Branch: DbP
CVS Tags: r1
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
initial import

1 dpavlin 1.1 #!/usr/local/bin/perl -w
2    
3     use LWP::UserAgent;
4     use strict;
5     use DBI;
6    
7     my $dbh = DBI->connect("DBI:Pg:dbname=corp","","") || die $DBI::errstr;
8    
9     my $ua = new LWP::UserAgent;
10     $ua->agent("pliva_harvester 0.0");
11     $ua->timeout(60);
12     $ua->env_proxy();
13    
14     my $market=0;
15     my @markets = ('LSE','FTSE','bug1','bug2','bug3','bug4');
16     my @val;
17    
18     my $close_time='23:23:23 CET';
19    
20     sub insert {
21     my $sql="insert into stocks values ('".shift(@val)."','".$markets[$market]."',".join(",",@val).")";
22     $sql=~s/,\+(\d)/,$1/g; # nuke + which pgsql doesn't like
23     $dbh->do("$sql") || die "$sql\n".$DBI::errstr;
24     $market++
25    
26     }
27    
28     my $req = HTTP::Request->new(GET =>"http://analysis.esi.co.uk/display.cgi?PLVD");
29     my $res = $ua->request($req);
30     if ($res->is_success) {
31     foreach (split(/\n/, $res->content)) {
32     chomp;
33     if (m, at (\d+:\d\d) on (\d+\s\w+\s\d+),i) {
34     my ($time,$date) = ($1,$2);
35     insert() if (defined(@val));
36     undef @val;
37     push @val,"$date $time GMT";
38     $dbh->do("delete from stocks where date='$date $close_time'");
39     # print "delete from stocks where date='$date $close_time'";
40     } elsif (m, at close on (\d+\s\w+\s\d+),i) {
41     my ($time,$date) = ($close_time,$1);
42     insert() if (defined(@val));
43     undef @val;
44     push @val,"$date $time";
45     }
46     if (m,<td VALIGN="MIDDLE" ALIGN="CENTER" HEIGHT="30"><FONT SIZE="-1" FACE="Verdana"><b>([-\+]*\d+\.\d+)</b>,i) {
47     push @val,$1;
48     }
49    
50     }
51     insert();
52     }
53    
54     $dbh->disconnect;

  ViewVC Help
Powered by ViewVC 1.1.26