Skip Menu |
 

This queue is for tickets about the Finance-Quote CPAN distribution.

Report information
The Basics
Id: 62619
Status: rejected
Priority: 0/
Queue: Finance-Quote

People
Owner: Nobody in particular
Requestors: Biggles [...] gmx.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: VWD.pm completely changed again
Date: Mon, 01 Nov 2010 17:31:36 +0100
To: bug-Finance-Quote [...] rt.cpan.org
From: Biggles <Biggles [...] gmx.de>
Download (untitled) / with headers
text/plain 303b
Hi all, VWD.pm needs to be changed again after multiple changes on the finanztreff.de pages. As I require some stocks from that site, I have "rewritten" the code. I'm not a programmer, so it's not polished, but at least it works for me. Maybe someone else can make use of it ... Greetings Biggles
Download VWD.pm
text/x-perl 6.2k

Message body is not shown because sender requested not to inline it.

From: Thomas.Eschenbacher [...] gmx.de
Download (untitled) / with headers
text/plain 149b
Hello, I attached my updated version of VWD.pm, which additionally provides values for the "symbol"(ISIN), the "name" and the "time" field. Thomas
Subject: VWD.pm
Download VWD.pm
text/x-perl 6.2k
#!/usr/bin/perl -W # # Copyright (C) 1998, Dj Padzensky <djpadz@padz.net> # Copyright (C) 1998, 1999 Linas Vepstas <linas@linas.org> # Copyright (C) 2000, Yannick LE NY <y-le-ny@ifrance.com> # Copyright (C) 2000, Paul Fenwick <pjf@cpan.org> # Copyright (C) 2000, Brent Neal <brentn@users.sourceforge.net> # Copyright (C) 2000, Volker Stuerzl <volker.stuerzl@gmx.de> # Copyright (C) 2003,2005,2006 Jörg Sommer <joerg@alea.gnuu.de> # Copyright (C) 2008 Martin Kompf (skaringa at users.sourceforge.net) # Copyright (C) 2010 Thomas Eschenbacher (thomas.eschenbacher at gmx.de) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA # # # This code derived from Padzensky's work on package Finance::YahooQuote, # but extends its capabilites to encompas a greater number of data sources. # # This code was developed as part of GnuCash <http://www.gnucash.org/> # ============================================================= package Finance::Quote::VWD; require 5.005; use strict; use LWP::UserAgent; use HTTP::Request::Common; use HTML::TreeBuilder; # use vars qw/$VERSION $VWD_FUNDS_URL/; use vars qw/$VERSION/; $VERSION = '1.17'; sub methods { return (vwd => \&vwd); } sub labels { return (vwd => [qw/currency date isodate name price last symbol time/]); } # ======================================================================= # The vwd routine gets quotes of funds from the website of # vwd Vereinigte Wirtschaftsdienste GmbH. # # This subroutine was written by Volker Stuerzl <volker.stuerzl@gmx.de> # and adjusted to match the new vwd interface by Jörg Sommer # Trim leading and tailing whitespaces (also non-breakable whitespaces) sub trim { $_ = shift(); s/^\s*//; s/\s*$//; s/&nbsp;//g; return $_; } # Trim leading and tailing whitespaces, leading + and tailing %, leading # and tailing &plusmn; (plus minus) and translate german separators into # english separators. Also removes the thousands separator in returned # values. sub trimtr { $_ = shift(); s/&nbsp;//g; s/&plusmn;//g; s/^\s*\+?//; s/\%?\s*$//; tr/,./.,/; s/,//g; return $_; } sub vwd { my $quoter = shift; my $ua = $quoter->user_agent(); my @funds = @_; return unless (@funds); my %info; foreach my $fund (@funds) { $info{$fund, "source"} = "VWD"; $info{$fund, "success"} = 0; $info{$fund, "errormsg"} = "Parse error"; my $response = $ua->get( "http://www.finanztreff.de/kurse_einzelkurs_suche.htn" . "?u=100&suchbegriff=".$fund ); if ($response->is_success) { my $html = $response->content; my $tree = HTML::TreeBuilder->new; $tree->parse($html); # date from the top of the page my $date_time = $tree->look_down( "_tag", "span", "class", "time"); next if not $date_time; if ($date_time->as_text =~ /(\d\d)\.(\d\d)\. \d\d:\d\d/) { $quoter->store_date(\%info, $fund, {day => $1, month => $2}); } # <div class="wpHeadline> contains name + date + price my $wpheadline = $tree->look_down( "_tag", "div", "class", "wpHeadline" ); next if not $wpheadline; # <h1> contains the name of the symbol my $head = $wpheadline->find("h1"); next if not $head; $info{$fund, "name"} = trimtr($head->as_text); # <div class="wpKurs"> contains price and date my $wpkurs = $wpheadline->look_down( "_tag", "div", "class", "wpKurs" ); next if not $wpkurs; # <div class="datum"> contains date my $time = $wpkurs->look_down( "_tag", "div", "class", "datum" ); if ($time) { $info{$fund, "time"} = $time->as_trimmed_text; } # <div class="kurs"> contains price my $kurs = $wpkurs->look_down( "_tag", "div", "class", "kurs"); next if not $kurs; $info{$fund, "price"} = $info{$fund, "last"} = trimtr($kurs->as_text); foreach ($kurs->descendants) { $_->delete; } # <li id="scrollup"> contains ISIN (symbol) my $scrollup = $tree->look_down( "_tag", "li", "id", "scrollup" ); next if not $scrollup; my @span = $scrollup->find("span"); print($span[4]->as_text . "\n"); if ($span[2]->as_trimmed_text =~ /ISIN:(.*)/) { $info{$fund, "symbol"} = $1; } # <table class="portraitKurse"> contains currency as 3rd <li> my $wpinfo = $tree->look_down( "_tag", "table", "class", "portraitKurse" ); if ($wpinfo) { my @tr = $wpinfo->find("tr"); my @td = $tr[0]->find("td"); $info{$fund, "currency"} = substr($td[2]->as_text, 0, 3); } # fund ok $info{$fund, "success"} = 1; $info{$fund, "errormsg"} = ""; $tree->delete; } else { $info{$fund, "success"} = 0; $info{$fund, "errormsg"} = "HTTP error"; } } return wantarray() ? %info : \%info; } 1; =head1 NAME Finance::Quote::VWD - Obtain quotes from vwd Vereinigte Wirtschaftsdienste GmbH. =head1 SYNOPSIS use Finance::Quote; $q = Finance::Quote->new; %stockinfo = $q->fetch("vwd","847402"); =head1 DESCRIPTION This module obtains information from vwd Vereinigte Wirtschaftsdienste GmbH http://www.vwd.de/. Many european stocks and funds are available, but at the moment only funds are supported. Information returned by this module is governed by vwd's terms and conditions. =head1 LABELS RETURNED The following labels may be returned by Finance::Quote::vwd: currency date isodate name price last symbol time. =head1 SEE ALSO vwd Vereinigte Wirtschaftsdienste GmbH, http://www.vwd.de/ =cut
From: Thomas.Eschenbacher [...] gmx.de
Hi, once again the vwd.de page changed, so here is another update... kind regards, Thomas
Subject: VWD.pm
Download VWD.pm
text/x-perl 6.2k
#!/usr/bin/perl -W # # Copyright (C) 1998, Dj Padzensky <djpadz@padz.net> # Copyright (C) 1998, 1999 Linas Vepstas <linas@linas.org> # Copyright (C) 2000, Yannick LE NY <y-le-ny@ifrance.com> # Copyright (C) 2000, Paul Fenwick <pjf@cpan.org> # Copyright (C) 2000, Brent Neal <brentn@users.sourceforge.net> # Copyright (C) 2000, Volker Stuerzl <volker.stuerzl@gmx.de> # Copyright (C) 2003,2005,2006 Jörg Sommer <joerg@alea.gnuu.de> # Copyright (C) 2008 Martin Kompf (skaringa at users.sourceforge.net) # Copyright (C) 2011 Thomas Eschenbacher (thomas.eschenbacher at gmx.de) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA # # # This code derived from Padzensky's work on package Finance::YahooQuote, # but extends its capabilites to encompas a greater number of data sources. # # This code was developed as part of GnuCash <http://www.gnucash.org/> # ============================================================= package Finance::Quote::VWD; require 5.005; use strict; use LWP::UserAgent; use HTTP::Request::Common; use HTML::TreeBuilder; # use vars qw/$VERSION $VWD_FUNDS_URL/; use vars qw/$VERSION/; $VERSION = '1.17'; sub methods { return (vwd => \&vwd); } sub labels { return (vwd => [qw/currency date isodate name price last symbol time/]); } # ======================================================================= # The vwd routine gets quotes of funds from the website of # vwd Vereinigte Wirtschaftsdienste GmbH. # # This subroutine was written by Volker Stuerzl <volker.stuerzl@gmx.de> # and adjusted to match the new vwd interface by Jörg Sommer # Trim leading and tailing whitespaces (also non-breakable whitespaces) sub trim { $_ = shift(); s/^\s*//; s/\s*$//; s/&nbsp;//g; return $_; } # Trim leading and tailing whitespaces, leading + and tailing %, leading # and tailing &plusmn; (plus minus) and translate german separators into # english separators. Also removes the thousands separator in returned # values. sub trimtr { $_ = shift(); s/&nbsp;//g; s/&plusmn;//g; s/^\s*\+?//; s/\%?\s*$//; tr/,./.,/; s/,//g; return $_; } sub vwd { my $quoter = shift; my $ua = $quoter->user_agent(); my @funds = @_; return unless (@funds); my %info; foreach my $fund (@funds) { $info{$fund, "source"} = "VWD"; $info{$fund, "success"} = 0; $info{$fund, "errormsg"} = "Parse error"; my $response = $ua->get("http://www.finanztreff.de/". "kurse_einzelkurs_uebersicht.htn?s=".$fund); if ($response->is_success) { my $html = $response->content; my $tree = HTML::TreeBuilder->new; $tree->parse($html); # date from the top of the page my $date_time = $tree->look_down( "_tag", "span", "class", "time"); next if not $date_time; if ($date_time->as_text =~ /(\d\d)\.(\d\d)\. \d\d:\d\d/) { $quoter->store_date(\%info, $fund, {day => $1, month => $2}); } # wpHeadLine contains a <h1> with the name my $wpheadline = $tree->look_down( "_tag", "div", "class", "wpHeadLine" ); next if not $wpheadline; my @name = $wpheadline->find("h1"); $info{$fund, "name"} = $name[0]->as_trimmed_text; # all other info below <div class=contentContainer> my $content = $tree->look_down( "_tag", "div", "class", "contentContainer" ); next if not $content; # wpKurs my $wpkurs = $tree->look_down( "_tag", "div", "class", "wpKurs" ); next if not $wpkurs; my $time = $wpkurs->look_down( "_tag", "div", "class", "datum" ); if ($time) { $info{$fund, "time"} = $time->as_trimmed_text; } my $kurs = $wpkurs->look_down( "_tag", "div", "class", "kurs"); next if not $kurs; $info{$fund, "price"} = $info{$fund, "last"} = trimtr($kurs->as_text); # scrollup contains WKN, ISIN, Symbol my $scrollup = $tree->look_down( "_tag", "li", "id", "scrollup" ); next if not $scrollup; my @scroll = $scrollup->find("span"); # $scroll[0] -> WKN # $scroll[2] -> ISIN # $scroll[4] -> Symbol my @isin = split(/:/,$scroll[2]->as_text); $info{$fund, "symbol"} = $isin[1]; # <ul> contains currency as 3rd <li> my $wpinfo = $content->look_down( "_tag", "table", "class", "portraitKurse" ); if ($wpinfo) { my @tr = $wpinfo->find("tr"); my @td = $tr[0]->find("td"); # $td[1] also contains current price $info{$fund, "currency"} = $td[2]->as_text; } # fund ok $info{$fund, "success"} = 1; $info{$fund, "errormsg"} = ""; $tree->delete; } else { $info{$fund, "success"} = 0; $info{$fund, "errormsg"} = "HTTP error"; } } return wantarray() ? %info : \%info; } 1; =head1 NAME Finance::Quote::VWD - Obtain quotes from vwd Vereinigte Wirtschaftsdienste GmbH. =head1 SYNOPSIS use Finance::Quote; $q = Finance::Quote->new; %stockinfo = $q->fetch("vwd","847402"); =head1 DESCRIPTION This module obtains information from vwd Vereinigte Wirtschaftsdienste GmbH http://www.vwd.de/. Many european stocks and funds are available, but at the moment only funds are supported. Information returned by this module is governed by vwd's terms and conditions. =head1 LABELS RETURNED The following labels may be returned by Finance::Quote::vwd: currency date isodate name price last symbol time. =head1 SEE ALSO vwd Vereinigte Wirtschaftsdienste GmbH, http://www.vwd.de/ =cut
thanks for the work VWD is working through gihub pull -- Erik


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.