/[corp]/esi/filter2.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

Diff of /esi/filter2.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Wed Feb 6 13:01:24 2002 UTC revision 1.4 by dpavlin, Thu Feb 7 11:10:56 2002 UTC
# Line 32  my $close_time='21:21:21 CET'; Line 32  my $close_time='21:21:21 CET';
32    
33  sub insert {  sub insert {
34          my ($date,$curr,$change,$change_pcnt,$high,$low,$open) = @val;          my ($date,$curr,$change,$change_pcnt,$high,$low,$open) = @val;
35          my $sql="insert into stocks values ('$date','LSE',$curr,$change,$high,$low,$open)";          my $sth = $dbh->prepare("select count(date) from stocks where date='$date'");
36          $sql=~s/,\+(\d)/,$1/g;  # nuke + which pgsql doesn't like          $sth->execute();
37          $dbh->do("$sql") || die "$sql\n".$DBI::errstr;          my ($nr) = $sth->fetchrow_array;
38          print_debug("sql: $sql\n");          if ($nr == 0) {
39                    my $sql="insert into stocks values ('$date','LSE',$curr,$change,$high,$low,$open)";
40                    $sql=~s/,\+(\d)/,$1/g;  # nuke + which pgsql doesn't like
41                    $dbh->do("$sql") || die "$sql\n".$DBI::errstr;
42                    print_debug("sql: $sql\n");
43            } else {
44                    print_debug("skip: $date\n");
45            }
46  }  }
47    
48  my $req = HTTP::Request->new(GET =>'http://custom.marketwatch.com/custom/alliance/ftmw/invrel.asp?siteid=!plivadd-0773-4F6D-DHID-QN1112NFTD0X&symb=PLVD');  my $req = HTTP::Request->new(GET =>'http://custom.marketwatch.com/custom/alliance/ftmw/invrel.asp?siteid=!plivadd-0773-4F6D-DHID-QN1112NFTD0X&symb=PLVD');
# Line 46  if ($res->is_success) { Line 53  if ($res->is_success) {
53      foreach (split(/[\n\r]+/, $res->content)) {      foreach (split(/[\n\r]+/, $res->content)) {
54          chomp;          chomp;
55          print_debug("line: $_\n");          print_debug("line: $_\n");
56          if (m,class="ft-quotedate">(\d+:\d+) (\d+)/(\d+)/(\d+),i) {          if (m,class="ft-quotedate">(\d+):(\d+) (\d+)/(\d+)/(\d+),i) {
57                  my ($time,$dd,$mm,$yy) = ($1,$2,$3,$4);                  my ($h,$m,$dd,$mm,$yy) = ($1,$2,$3,$4,$5);
58                  my $date=($yy+2000)."-$mm-$dd";                  my $date=($yy+2000)."-$mm-$dd";
59                    my (undef,undef,$local_h) = localtime(time);
60                    $h += 12 if ($local_h - $h > 12);
61                    my $time="$h:$m";
62                  print_debug("time: $time date: $date");                  print_debug("time: $time date: $date");
63                  insert() if (@val);                  insert() if (@val);
64                  undef @val;                  undef @val;
65                  push @val,"$date $time";                  push @val,"$date $time";
66                  $dbh->do("delete from stocks where date='$date $close_time'");  #               $dbh->do("delete from stocks where date='$date $close_time'");
67          }          }
68          if (m,class="ft-quote[^"]+".*<nobr>(\d+\.\d+)</nobr>,i) {          if (m,class="ft-quote[^"]+".*<nobr>(\d+\.\d+)</nobr>,i) {
69                  push @val,$1;                  push @val,$1;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.26