Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Posting on a site using mechanize

by cesapun (Acolyte)
on Aug 15, 2012 at 10:44 UTC ( #987530=perlquestion: print w/replies, xml ) Need Help??
cesapun has asked for the wisdom of the Perl Monks concerning the following question:

Hello !

So,i have this code

#!/usr/bin/perl -w use strict; use warnings; use WWW::Mechanize; my $torrent_name = "Unmechanical-TiNYiSO"; my $cat = "Games"; my $mech = WWW::Mechanize->new( autocheck => 1);#Initializes WWW::Mech +anize ##############PRINT ON ESTORRENTS########### print "[INFO] Posting on ESTorrents!\n"; $mech->get(""); $mech->submit_form( form_id => 'addCommentForm'); $mech->field('name' , 'test'); $mech->field('body' , 'lol'); $mech->field('category' , 'Category:'); $mech->click(); print "[INFO] All Finished!\n"; #Alerts The User my $e = $mech->content(format => 'text'); print $e;

but is does not seems to work

This is the source code from that site:

<div id="addCommentContainer"> <p>Add a Torrent</p> <form id="addCommentForm" method="post" action=""> <div> <label for="name">Info</label> <input type="text" name="name" id="name" /> <label for="body">Torrent Name</label> <textarea name="body" id="body" cols="20" rows="5"></texta +rea> <label for="cat">Category</label> <input type="text" name="category" id="category" /> <input type="submit" id="submit" value="Submit" /> </div> </form> </div>

What is the problem?Because after running that script,nothing appears on that site.

Replies are listed 'Best First'.
Re: Posting on a site using mechanize
by Anonymous Monk on Aug 15, 2012 at 11:03 UTC

      Hmmm....this means that's something wrong with my code?

      I'm fairly new to perl language.:)

        Hmmm....this means that's something wrong with my code?


        You're talking to a space-alien (random website), and those are usually tested using browser like firefox...

        so if it works with firefox, all you have to do is get your program to talk using the same accent and everything (http headers...)

        Unless you have an error message to report :)

Re: Posting on a site using mechanize
by Anonymous Monk on Aug 15, 2012 at 12:09 UTC
    $mech->submit_form( form_id => 'addCommentForm');
    and paste it over

      Ehh.....i have just build another site and now it works.

      Thanks anyway.Close this topic.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://987530]
Approved by Corion
[Discipulus]: dear brother karl has "Furthermore I consider that Donald Trump must be impeached as soon as possible" in his sig
[erix]: ah, thanks Discipulus
[1nickt]: erix perhaps you could kindly point out your technique to roho and everyone will be happy.
[Discipulus]: but i'm also animalist, so i' hirted by 1nickt's sig: The way forward always starts with a mammal test... grin..
[erix]: I might if I did remember. It's probably somewhere in the site docs
[uhClem]: I don't favor that sort of thing around here but the place for our politics is wherever we live.
[uhClem]: And besides, the objection to it was off-topic.
[Discipulus]: 1nickt hide signature is a positive action; i think is not a solution here

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2017-06-22 12:36 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.