|
|
@ -37,6 +37,10 @@ class WikiBot
|
|
|
|
return @wiki + "index.php?title=" + url_encode(title) + "&redirect=no"
|
|
|
|
return @wiki + "index.php?title=" + url_encode(title) + "&redirect=no"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def url_page (title)
|
|
|
|
|
|
|
|
return @wiki + "index.php?title=" + url_encode(title)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def url_raw (title)
|
|
|
|
def url_raw (title)
|
|
|
|
return @wiki + "index.php?title=" + url_encode(title) + "&action=raw"
|
|
|
|
return @wiki + "index.php?title=" + url_encode(title) + "&action=raw"
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -197,6 +201,31 @@ class WikiBot
|
|
|
|
return articles
|
|
|
|
return articles
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_categories(title)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if is_redirect?(title)
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
categories = []
|
|
|
|
|
|
|
|
categories_html = @client.get_content(url_page(title)).scan(/<div id="catlinks">(.*?)<\/div>/)[0][0]
|
|
|
|
|
|
|
|
categories_html.scan(/title="(.*?)"/) do |m|
|
|
|
|
|
|
|
|
category = CGI.unescapeHTML(m[0])
|
|
|
|
|
|
|
|
categories.push(category)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return categories[1..-1]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_in_category?(title, category)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if is_redirect?(title)
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_categories(title).member?(category)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end # class WikiBot
|
|
|
|
end # class WikiBot
|
|
|
|
|
|
|
|
|
|
|
|
end # module MediaWikiBot
|
|
|
|
end # module MediaWikiBot
|
|
|
|