Last active
January 12, 2017 01:18
-
-
Save elifoster/eaa10cb87ca151426fb34ffbb7e9d307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script scans all the links in a navbox and prints all the links that are not for the correct mod. | |
# For example, links to disambiguation pages, or pages for other mods. | |
# Note: It will also probably include template links and redirects that you can safely ignore. | |
require 'mediawiki/butt' | |
butt = MediaWiki::Butt.new('https://ftb.gamepedia.com/api.php', use_continuation: true, default_query_limit: 'max') | |
butt.login(USERNAME, PASSWORD) | |
# If you are using a lazy loaded navbox, do 'Template:Navbox Thing/content'. Otherwise just do 'Template:Navbox Thing' | |
butt.get_all_links_in_page('Template:Navbox Thing').each do |link| | |
text = butt.get_text(link) | |
next if text.nil? | |
# Change Thing to whatever you want. For example, Category:Witchery. | |
next if text.include?('[[Category:Thing]]') | |
next if text.include?('[[Category:Thing{{L}}]]') | |
p link | |
end # Note: If you are running this in Pry (maybe IRB too, can't remember), you can add a semicolon ; to this line to stop it from showing you the entire `all_links` array at the end of this statement ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment