coder57 has asked for the wisdom of the Perl Monks concerning the following question:
#There are 3 articles per page all having the text_regex articles, one underneath the other for ($start=1;$start<=3;$start++) { #at this particular point I have 3 articles per page as stated(there are scroll down options to edit the articles or delete the articles, but they are in javascript as stated earlier), and there are 3 pages, I would like to edit the articles on the first page with the same text in $text, and the the next three articles on the next page with the text in $text2, and the next three articles on the last page with $text3, I am a little stuck :( on how to proceed from here. $mech1->click("Article1"); #I have 3 articles at this point, all having the link article, but three of them of different lines, one underneath the other, I would like to go through each of them, click on the edit article link(which is in javascript, as well as the delete article link, but I would like to select the edit article link) and submit it with the amended text in $text..$text2...$text3.#! perl\bin\perl use strict; use warnings; use Data::Dumper; use WWW::Mechanize; my $text ='My new article...'; my $text2 = 'My second article...'; my $text3 = 'My third article...'; my $start; my $mech1 = WWW::Mechanize->new( agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', cookie_jar => {}); $mech1->get("http://www.example.com"); $mech1->form(1); $mech1->field('username',"username"); $mech1->field('password',"password"); $mech1->click("login"); if ($mech1->success){ print "successfully logged on \n";} else{print +!$;} $mech1->follow_link( text_regex => qr/Articles/i );
I would like to do this for each articles on each page, after clicking on the text_reg of articles(by selection of articles, however it is in javascript), then clicking on the edit button, and filling in the new textif( $mech1->success){print "success \n";} else{print !$;} $mech1->click("Edit article"); if( $mech1->success){print "Editing article \n";} else{print !$;} $mech1->field('text',"$text");
Would appreciate any help$mech1->click("submit"); if ($mech1->success){ print "article successfully submitted \n";} else +{print !$;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: editing an article that also uses javascript with mechanize
by marto (Cardinal) on Aug 06, 2006 at 14:48 UTC | |
by coder57 (Novice) on Aug 08, 2006 at 10:29 UTC | |
by marto (Cardinal) on Aug 08, 2006 at 10:46 UTC | |
|
Re: editing an article that also uses javascript with mechanize
by bart (Canon) on Aug 08, 2006 at 10:54 UTC | |
by adrianh (Chancellor) on Aug 09, 2006 at 08:20 UTC |