Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

(jeffa) Re: Pity da foo who misspells Monastery

by jeffa (Bishop)
on May 06, 2003 at 14:30 UTC ( [id://255894]=note: print w/replies, xml ) Need Help??


in reply to Pity da foo who misspells Monastery

I just Super Searched and found eleven occurances occurences of me misspelling monastery. Sheesh! Even my 500th Post was tainted! ;)

For the record, these days when i need to spell monastery, i just remember that the a and the e are what get confused - so i simply use the fact that (sorting alpha-wise) a comes before e in this case: monastery.

UPDATE: here is the code as promised. It worked well for my needs, but tweaking will be necessary for your needs. I must admit that i screwed up and lost the content for 79578. I tried to get a copy from http://perlmonks.thepen.com but i was too late. What did i do wrong? I simply used this:

$agent->field('note_doctext');
instead of this:
$agent->field('note_doctext',$textarea);
Ouch!! Oh well, live and learn. Here is the complete code, and be careful!
use strict; use warnings; use XML::XPath; use XML::LibXML; use WWW::Mechanize; use HTTP::Cookies; use Data::Dumper; use constant URL => 'http://www.perlmonks.org'; my $user_name = ; my $user_id = ; my $password = ; my $search = 'onestary'; my $replace = 'onastery'; my $agent = login($user_name,$password); my $raw_results = raw_search_results($agent,$user_name,$search); my @link = get_links($raw_results); replace($agent,$_,$search,$replace) for @link; sub replace { my ($agent,$link,$search,$replace) = @_; $agent->get(URL . $link); print STDERR "got $link ..."; my $textarea = get_textarea($agent->{content}); warn "no textarea for $link" and return unless $textarea; $textarea =~ s/$search/$replace/g; $agent->form(2); $agent->field('note_doctext',$textarea); $agent->click('sexisgood'); print STDERR "done!\n"; } sub get_textarea { my $html = shift; my $dom = get_dom($html); my @node = $dom->findvalue(q|//textarea[@name='note_doctext']|); return $node[0]; } sub get_links { my $html = shift; my $dom = get_dom($html); my @link; for ($dom->findnodes(q|//table[@width='100%']/tr/td/a|)) { my $href = $_->getAttribute('href'); next unless $href; my ($id) = $href =~ /(\d+)$/; $id ||= 0; push @link, $href if $id > $user_id; } return @link; } sub get_dom { XML::LibXML->new->parse_html_string(shift) } sub raw_search_results { my ($agent,$author,$text) = @_; # Super Search is node 3989 $agent->get(URL . '/index.pl?node_id=3989'); $agent->form(2); $agent->field(@$_) for ( ['BIT', $text], # search text [qw(xa 0 1)], # include ... ['a', $author], # author ); $agent->click('go'); print STDERR "got search results ...\n"; return $agent->{content}; } sub login { my ($user,$pass) = @_; my $agent = WWW::Mechanize->new(); $agent->cookie_jar(HTTP::Cookies->new()); # Reviews is a fast loading page to login with $agent->get(URL . '/index.pl?node_id=21144'); $agent->form(2); $agent->field(@$_) for ( [qw(op login)], ['user', $user], ['passwd',$pass], ); $agent->click('login'); print STDERR "logged in ...\n"; return $agent; }

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: Pity da foo who misspells Monastery
by benn (Vicar) on May 06, 2003 at 14:44 UTC
    ...as encapsulated by the (now extended) little rhyme...
    When spelling Monastery, you need to know, The vowels are in order, except for the 'o'.
    :) cheers,Ben

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://255894]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found