Spent a bit longer on this than needs be with hindsight, so I figure i'd share the product of that time
Music stack doesn't have much in the way of an API, instead it requires manual navigation to upload change files. The change file also has an enormous amount of saved customisations on the upload form which would be numbingly tedious to fill out manually in the $mech itself
So! here's a short and effective means of putting inventory files up on Music Stack, using WWW::Mechanize to navigate from the login screen to the upload screen.
my $username = 'firstname.lastname@example.org';
my $password = 'mypw';
my $upfile = '/path/to/additions.csv';
my $mech = WWW::Mechanize->new() or die $!;
$mech->get(q#http://www.musicstack.com/login.cgi#) or die $!;
#need to use sequential identifiers when forms are either nameless
+ or share the same name
$mech->field ('user' => $username);
$mech->field ('pw' => $password);
$mech->click_button(name => "login");
#now on the user account page
$mech->follow_link( text => 'Upload' );#case sensitive
#now on the inventory management page
$mech->form_name('form'); # 2 forms on page - other is 'search'
# 3 options here - add is incremental
$mech->set_fields('delete' => 'add');
$mech->field('upfile' => $upfile );
$mech->click_button(value => 'Upload File');
#the file is uploaded and the status screen displayed here
print $mech-> content();
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||