in reply to extracting from web and adding to csv file with their links
OK, since I'm not entirely sure what you need, perhaps you could elaborate. To start, this is the first few lines from one of the output files:
SYMBOL|NAME|LAST TRADE|CHANGE|VOLUME|RELATED INFO BAC|Bank of America Corporation Com|7.82 4:00PM EDT|0.24 (2.98%)|120,1 +61,969|Chart, Profile, More JPM|JP Morgan Chase & Co. Common St|34.38 4:02PM EDT|1.50 (4.18%)|58,5 +29,307|Chart, Profile, More SIRI|Sirius XM Radio Inc.|2.09 4:00PM EDT|0.05 (2.45%)|52,421,104|Char +t, Profile, More
Are you wanting to change "Chart, Profile, More" into "Chart, Profile, More"? If so, since you are only collecting the text and not links from the yahoo pages, your best bet is to harvest the symbols (e.g., BAC) from what you have and stick them into Yahoo's link template (e.g. http://finance.yahoo.com/q/bc?s=INSERT_SYMBOL_HERE for Charts). Assuming this is what you are trying to do, I wrote to following as a proof-of-concept and used it to replace print US $lin[1];:
for my $lin_line ( split (/\n/, $lin[1]) ) { my ( $symbol ) = $lin_line =~ m/(\w*)|/; next if $symbol eq "SYMBOL"; $lin_line =~ s|(Chart)|$1: http://finance.yahoo.com/q/bc?s=$symbol +|; } continue { print US $lin_line, "\n"; }
The output looks like:
SYMBOL|NAME|LAST TRADE|CHANGE|VOLUME|RELATED INFO BAC|Bank of America Corporation Com|7.82|Jul 5|0.24 (2.98%)|120,161,96 +9|Chart: http://finance.yahoo.com/q/bc?s=BAC, Profile, More JPM|JP Morgan Chase & Co. Common St|34.38|Jul 5|1.50 (4.18%)|58,529,30 +7|Chart: http://finance.yahoo.com/q/bc?s=JPM, Profile, More SIRI|Sirius XM Radio Inc.|2.09|Jul 5|0.05 (2.45%)|52,421,104|Chart: ht +tp://finance.yahoo.com/q/bc?s=SIRI, Profile, More
If this is what you are going for, you should elaborate on so that it reports links for 'Profile' and 'More' for all your output files.
One other thing... You are saving your files as csv, but the data you output is not comma-delimited (unless you only want 3 columns).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: extracting from web and adding to csv file with their links
by programmer.perl (Beadle) on Jul 06, 2012 at 17:24 UTC | |
by frozenwithjoy (Priest) on Jul 06, 2012 at 19:32 UTC |