Difference between revisions of "Yi-bot.pl"

From Organic Design wiki
(Make more generic)
m
Line 20: Line 20:
 
@articles = ('foo','bar');
 
@articles = ('foo','bar');
 
 
# Loop through the 64 hexagrams
+
# Loop through the article titles
 
for $title (@articles) {
 
for $title (@articles) {
 
print "$title\n";
 
print "$title\n";
Line 36: Line 36:
 
caction => 'replace',
 
caction => 'replace',
 
summary => $summary,
 
summary => $summary,
content => "$_\n__NOEDITSECTION__"
+
content => $_
 
);
 
);
 
$client->post($wiki,\%form);
 
$client->post($wiki,\%form);

Revision as of 21:09, 19 October 2007

  1. !/usr/bin/perl
  2. Script to create or adjust many articlesOur Perl scripts.
  1. Set up a user agent

use HTTP::Request; use LWP::UserAgent; $client = LWP::UserAgent->new(

       cookie_jar => {},
       agent => 'Mozilla/5.0',
       from => 'wikid.pl@organicdesign.co.nz',
       timeout => 10,
       max_size => 100000
       );
  1. Wiki script URL and comment to use for edit summary

$wiki = 'http://www.organicdesign.co.nz/wiki/index.php'; $summary = 'Yi-bot script';

  1. Your list of article titles

@articles = ('foo','bar');

  1. Loop through the article titles

for $title (@articles) { print "$title\n";

# If your adjusting existing articles, read the existing title's wikitext, otherwise read content from a file $response = $client->get("$wiki?title=$title&action=raw"); $_ = $response->content;

# If your adjusting existing articles, adjust the content here s/old/new/g;

# Update the article by posting a form using a Simple Forms request %form = ( title => $title, caction => 'replace', summary => $summary, content => $_ ); $client->post($wiki,\%form);

sleep(0.5); }