Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 17530
Status: rejected
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: dlombard [...] broadspire.com
Cc:
AdminCc:

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



Subject: There is no Form Number on that page.
Download (untitled) / with headers
text/plain 855b
Linux idx32.idx.net 2.4.17 #4 SMP Fri Feb 18 15:31:35 PST 2005 i686 unknown This is perl, v5.6.1 built for i686-linux I am using WWW::Mechanize 1.18. I am getting this error message: There is no form numbered 1 at ./regdomain.pl line 120 Can't call method "find_input" on an undefined value at /usr/local/lib/perl5/site_perl/5.6.1/WWW/Mechanize.pm line 1269, <STDIN> line 1. I have attached my script (regdomain.pl as regdomain_pl.txt) and an example of the text file it's supposed to parse (example.txt). The way it's supposed to work is like this: unix@host>./regdomain.txt example.txt If you review the file, you will see the URL that it attempts to get the HTML form from. Viewing its source should reveal the form fields my script is attempting to populate. Any help you can provide with this would be substantially appreciated. Thank you.
Subject: example.txt
Download example.txt
text/plain 717b
-----Original Message----- From: nobody@nowhere.com Sent: Tuesday, February 07, 2006 5:07 PM To: Shared Account setup Subject: Shared Web Hosting Order Century 21 Web Hosting Order Name: Someone Somebody-Hypehnated Company: Ultra Business, Inc. Address: 1234 Anywhere Blvd. City: Somewhere State: CA Zip: 90010 Country: United States Phone: 2135551212 Fax: 323-55-1212 Email: email@address.tld Card type: Visa Card No.: 1234567812345678 CCID: 000 Exp.: 02/2010 Order Total: 60.00 CP Username: 0123456 CP Password: owiekazowee FTP Passwd: ayeyiyi Hosting Term: 12 month(s) Requested Domains: thedomain.com (main domain - register me please, 1 year(s))
Subject: regdomain_pl.txt
Download regdomain_pl.txt
text/plain 4.7k
#!/usr/local/bin/perl # # regdomain.pl v1.00b # # usage: # ./regdomain.pl filename.txt # filename.txt contains the e-mail from sales@broadspire.com # For now, this only handles registering one domain name at a time. # For multiple domain names, or non-American registrations, you'l have to # go to the site yourself. # Fortunately, those domains are pretty rare. # Populate hash array called ordermail with text file... while ( $_ = <> ) { ($field, $input) = split /:\s*/, $_, 2; @fields = split ' ', $input; $ordermail{$field} = [ @fields ]; } # Parse the hash into variables for HTML form injection... $firstname = "$ordermail{Name}[0]"; $lastname = "$ordermail{Name}[1] $ordermail{Name}[2] $ordermail{Name}[3]"; $company = "$ordermail{Company}[0] $ordermail{Company}[1] $ordermail{Company}[2] $ordermail{Company}[3] $ordermail{Company}[4]"; $address = "$ordermail{Address}[0] $ordermail{Address}[1] $ordermail{Address}[2] $ordermail{Address}[3] $ordermail{Address}[4] $ordermail{Address}[5]"; $city = "$ordermail{City}[0] $ordermail{Address}[1] $ordermail{Address}[2]"; $state = "$ordermail{State}[0]"; $postalcode = "$ordermail{Zip}[0]"; $country = "$ordermail{Country}[0] $ordermail{Country}[1]"; $phno = "$ordermail{Phone}[0] $ordermail{Phone}[1] $ordermail{Phone}[2]"; # Take out non-numbers $phno =~ s/[^\d]//g; # Add +1. to the number because it's required. $phone = "\+1.$phno"; # A fax number is mandatory; if this is blank, we have to use all zeros. $faxno = "$ordermail{Fax}[0] $ordermail{Fax}[1] $ordermail{Fax}[2]"; $faxno =~ s/[^\d]//g; $fax = "\+1.$faxno"; if ($fax =~ /\+1\.$/) { $fax = "\+1.0000000000"; } $email = "$ordermail{Email}[0]"; $cardtype = "Visa"; $cardno = "4111111111111111"; # We have to split the expiry because it's two separate HTML form fields. $exp = "$ordermail{'Exp.'}[0]"; @expdate = split '/', $exp; $expmo = @expdate[0]; # Because sometimes the e-mail has a four digit year as opposed to two. $expy = @expdate[1]; if ($expy =~ /^0/) { $expyr = "20$expy"; } else { $expyr = $expy; } $login = "$ordermail{'CP Username'}[0]"; $pwd = "$ordermail{'CP Password'}[0]"; $domain = "$ordermail{'Requested Domains'}[0]"; $regyears = "$ordermail{'Requested Domains'}[7]"; $pdns = "ns1.idx.net"; $sdns = "ns2.idx.net"; # Tell the operator what's going on: print "Registering: $domain\n"; print "\n"; print "Domain Management Username: $login\n"; print "Domain Management Password: $pwd\n"; print "\n"; print "Registration Period: $regyears year(s)\n"; print "\n"; print "First Name: $firstname\n"; print "Last Name: $lastname\n"; print "Organization Name: $company\n"; print "Street Address: $address\n"; print "City: $city\n"; print "State\/Province: $state\n"; print "Postal Code: $postalcode\n"; print "Country: $country\n"; print "Telephone Number: $phone\n"; print "Fax Number: $fax\n"; print "E-Mail Address: $email\n"; print "\n"; print "Primary Name Server Hostname: $pdns\n"; print "Secondary Name Server Hostname: $sdns\n"; print "\n"; print "Using Method Type: $cardtype\n"; print "Using Card Number: $cardno\n"; print "Using Expiration Date: $expmo/$expyr\n"; print "\n"; print "OK to proceed? (Y/n): "; chomp(my $input = <STDIN>); if ($input =~ /^[Y]?$/i) { print "OK! "; } elsif ($input =~ /^[N]$/i) { print "Aborting as requested.\n"; exit; } # HTML Form Injection: print "Registering...\n"; # Use WWW::Mechanize, initialize our robot and fetch the good form... use WWW::Mechanize; my $robot = WWW::Mechanize->new(); my $url = "https://register.broadspire.com/reg/reg_system.cgi?action=bulk_order"; $robot->get($url); die unless ($robot->success); # Specify the Domain Management username and password... $robot->set_visible( 0, $login, $pwd, $pwd ); $robot->click(); die unless ($robot->success); print "Set Domain Management Username and Password.\n"; # Now fill out and submit the main domain name registration form... $robot->form_number(1); $robot->tick(flag_admin_use_contact_info); $robot->tick(flag_billing_use_contact_info); $robot->set_fields( domains => $domain, period => $regyears, confirm_password => $pwd, period => $regyears, owner_first_name => $firstname, owner_last_name => $lastname, owner_org_name => $company, owner_address1 => $address, owner_city => $city, owner_state => $state, owner_postal_code => $postalcode, owner_phone => $phone, owner_fax => $fax, owner_email => $email, fqdn1 => $pdns, fqdn2 => $sdns, p_cc_type => $cardtype, p_cc_num => $cardno, p_cc_exp_mon => $expmo, p_cc_exp_yr => $expyr, ); $robot->click(); die unless ($robot->success); # Order Now! $robot->click(); # Show the domain name order number... $msg = $robot->content; print $msg\n;


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.