Does anyone have any experience pulling MS Excel files off of the web? I have been unable to get a valid Excel file from a website. Here is what happens (Windows 2000 box, ActiveState perl):
- Connect to server, then authenticate
- Use LWP to GET the file of interest.
- Save the file to disk
When I do this, the file cannot be read by Excel, nor will ParseExcel read the file. I compared the downloaded file to a "reference" file that I created by opening the Excel file in IE & saving to disk. The files are very, very similar, but different.
Is there some special MS foo that is tripping me up, or am I missing something obvious like character encodings?
Here is an abbrviated version of my code:
use strict;
use warnings;
use LWP;
use Spreadsheet::ParseExcel;
my $url = 'http:// blah blah /login.asp';
my $browser = LWP::UserAgent->new;
$browser->cookie_jar({});
my $response = $browser->post( $url,
[ 'password' => 'pass',
'userid' => 'user',
'btnsubmit' => 'Submit',
]
);
$url = "http://blah blah getdata_RS.asp";
$response = $browser->get( $url );
my $exceldata = $response->content;
open (FILE, "> c:\\test.xls");
The file that I am pulling down is only one sheet, not an entire workbook.
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.