Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I found a perl script that sends sms using a third party free website. It was working fine until today. Today i noticed that the "div tag id" used to get the access of the textbox to enter the sender's phone number is changed from static to dynamic, ie, the id is dynamically generated so i can no longer use the static id. I am using the WWW::Mechanize to access the forms,so can ou tell me how do i obtain a variable value that is dynamically generated in a webpage and use in my perl script. Here is the complete sample code that i am using:

#!/usr/bin/perl use WWW::Mechanize; use Compress::Zlib; my $mech = WWW::Mechanize->new(); my $username = ""; #fill in username registered here my $keyword = ""; #fill in password here my $opt="-f"; my ($text,$mobile,$option); my @mobilenos; my $morenos = $ARGV[0]; @mobilenos = $morenos; $text = $ARGV[1]; $deb = 1; print "Total Character of message is ".length($text)."\n" if($deb); $text = $text."\n\n\n\n\n" if(length($text) < 135); $mech->get(""); unless($mech->success()) { exit; } $dest = $mech->response->content; print "Fetching...\n" if($deb); if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); $mech->update_html($dest); } $dest =~ s/<form name="loginForm"/<form action='..\/Login1.action' nam +e="loginForm"/ig; $mech->update_html($dest); $mech->form_with_fields(("username","password")); $mech->field("username",$username); print "Loggin...\n" if($deb); $mech->submit_form(); $dest= $mech->response->content; if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); $mech->update_html($dest); } foreach $mobile (@mobilenos){ # for loop begins chomp($mobile); print "\nMessage sending to ".($mobile)."\n"; $mech->get(""); $dest= $mech->response->content; if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); $mech->update_html($dest); } print "Sending ... \n" if($deb); ####I AM UNABLE TO GET THE FORM WITH FIELD MobNo AS ITS rqMob WHOSE VA +LUE IS DYNAMICALLY GENERATED##### $mech->form_with_fields(("MobNo","textArea")); $mech->field("MobNo",$mobile); $mech->field("textArea",$text); $mech->submit_form(); if($mech->success()) { print "Done \n" if($deb); } else { print "Failed \n" if($deb); exit; } $dest = $mech->response->content; if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); #print $dest if($deb); } if($dest =~ m/successfully/sig) { print "Message sent successfully \n" if($deb); } # foreach loop ends } print "Message sent to all the numbers\n Bye.\n"; exit; #EOF
To run the script i type: ./ phone_number_of_reciever 'message_to_be_sent' . PLEASE HELP ME WITH THIS PROBLEM AS THIS IS A IMPORTANT PART OF MY PROJECT. THANKS IN ADVANCE..

In reply to issue in perl script that sends sms using a third party website by ramyavictor89

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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, 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (4)
    As of 2015-12-02 05:19 GMT
    Find Nodes?
      Voting Booth?

      My keyboard shows this many letters:

      Results (34 votes), past polls