User:Xeon/scripts/makeeliteaq.pl


 * 1) !/usr/local/bin/perl


 * 1) This code works with http://gw.gamewikis.org as of the 1 August 2007


 * 1) INFORMATION
 * 2) A dynamic way to exact acquisition details from elite skill articles
 * 3) This script was originally not ment to be used again, therefore the script is not formated correctly for such a thing and is undocumented


 * 1) DISCLAIMER
 * 2) The original author User:Xeon does not take responsibility for your use of the software, you use this software at your own risk
 * 3) This script may be used & modified without restriction (public domain)


 * 1) INSTRUCTIONS
 * 2) change -> @lines = ("Category:Elite_skills", "Category:Elite_skills&from=Second+Wind");
 * 3) to the url of each list header, it does not automatically retrieve the urls of each category list
 * 4) some pages have details next to the acq details on purpose, these must be changed as they cannot be automatically removed
 * 5) checks the end of acq by finding "=" so if there are no ==related articles== it will ignore that acq, easy fix in script, i just manually fixed it instead of fixing the script because there were only 4 of them


 * 1) KNOWN BUGS

use LWP::Simple; use HTML::TreeBuilder; use HTML::Element;

my(@names); my(@profession); my(@attribute); my(@campaign); my(@skill_data);

@lines = ("Category:Elite_skills", "Category:Elite_skills&from=Second+Wind"); foreach(@lines) { $currentaddress = "http://gw.gamewikis.org/wiki?title=". $_;	print "Scanning skills ". $currentaddress. "\n"; $content = get($currentaddress); my $tree = HTML::TreeBuilder->new; $content =~ /Articles in category(.*) /s; $tree->parse_content($1); @elements = $tree->look_down('_tag', 'li'); foreach(@elements) { push(@names, $_->as_text); }	$tree->delete; }

print "Printing skill list\n"; foreach(@names) { print "\n--\n"; print(" ", $_, "\n");

my $edittree = HTML::TreeBuilder->new; $editcontent = get("http://gw.gamewikis.org/wiki?title=Template:" . $_ . "&action=edit"); $edittree->parse_content($editcontent); $closein = $edittree->look_down('_tag', 'textarea'); if($closein->as_text =~ m/attribute = (.*)/) { $thisattribute = $1; print "attribute: ". $thisattribute. "\n"; }	else {		print "attribute: No Attribute\n"; $thisattribute = "No Attribute"; }	if($closein->as_text =~ m/profession = (.*)/) { $thisprofession = $1; print "profession: ". $thisprofession. "\n"; }	else {		print "error getting profession\n"; }	if($closein->as_text =~ m/campaign = (.*)/) { $thiscampaign = $1; print "campaign: ". $thiscampaign. "\n"; }

$x = grep{$thisprofession eq $_} @profession; if(!$x) {		push(@profession, $thisprofession); print "New profession added: ". $thisprofession. "\n"; }	$x = grep{$thisattribute eq $_} @attribute; if(!$x) {		push(@attribute, $thisattribute); print "New attribute added: ". $thisattribute. "\n"; }	$x = grep{$thiscampaign eq $_} @campaign; if(!$x) {		push(@campaign, $thiscampaign); print "New campaign added: ". $thiscampaign. "\n"; }	push(@skill_stats, $_); push(@skill_stats, $thiscampaign); push(@skill_stats, $thisprofession); push(@skill_stats, $thisattribute); $edittree->delete; $edittree = HTML::TreeBuilder->new; $editcontent = get("http://gw.gamewikis.org/wiki?title=" . $_ . "&action=edit"); $edittree->parse_content($editcontent); $closeing = $edittree->look_down('_tag', 'textarea'); $closeing->as_text =~ /\[\[Signet of Capture]]:(.*?)=/s; $acq = $1; $acq =~ s/\n\n/\n/g; $acq =~ s/^\n//g; $acq =~ s/\n$//g; push(@skill_stats, $acq); push(@skill_data, [@skill_stats]); @skill_stats = ; }	@attribute = sort(@attribute); foreach(@profession) { open(outfile, ">" . $_ . ".txt"); print outfile "This page gives the locations of elite skills for the " . $_ . " at a glance.\n"; $cur_pro = $_; foreach(@attribute) { my $firstati = 1; $cur_att = $_; for $i (0 .. $#skill_data) {				if($skill_data[$i][2] eq $cur_pro) { if($skill_data[$i][3] eq $cur_att) { if($firstati) { print outfile "\n== " . $_ . " =="; $firstati = 0; } print outfile "\n (" . $skill_data[$i][1] . ")\n"; print outfile $skill_data[$i][4]. "\n"; }				}			}		}		print outfile "\n\n\n "; close(outfile); }