use WWW::Mechanize; use Data::Dumper; $login_email = "#########################"; $login_pwd = '######'; my $mech = WWW::Mechanize->new(); $create_obj = $mech->success(); $mech->agent_alias( 'Windows Mozilla' ); $create_alias = $mech->success(); $mech->get('https://zipcodedownload.com/login'); $first_get = $mech->success(); $mech->submit_form( with_fields => { Email => $login_email, Password => $login_pwd }, button => "" ); ### Up to here login looks good $submit = $mech->success(); @inputs= $mech->find_all_inputs(); $inputs = scalar(@inputs); print "num inpits is $inputs\n"; $found_page = $mech->content; $found_page =~ /PopDownLoadProducts\('([^']+)'/; print "Poppy is $1\n"; $download_page = "https://zipcodedownload.com/customer/GetDownLoadProductFormat?id=$1"; $mech->get("$download_page"); $second_get = $mech->success(); print "Got product is $second_get\n"; $download_page = $mech->content; @download_pages = split /\\r\\n/, $download_page; ## I successfully find the download box print "Num elements is " . scalar(@download_pages) . "\n"; foreach $page (@download_pages) { $page =~ /\\u0027(.+)\\u0027\)\\"\\u003eComma/; $foundit=""; $foundit = $1; chomp $foundit; } ## I have found the .csv format to download and extracted that filename in the Fiddler output below print "Found stuff is '|' $foundit '|'\n"; $foundit =~ s/%/%25/g; ## I've replaced the % with %25 print "NEWFound stuff is '|' $foundit '|'\n"; print "filename=$foundit"; ## This is where I get the error page instead of the JSON return $amazon_parameters = $mech->post("https://zipcodedownload.com/customer/DownloadProdCut",filename=>"$foundit", Content_type=>'application/x-www-form-urlencoded'); print $mech->success(); print Data::Dumper->Dump([$amazon_parameters],[qw(a*)]);