@@ -36,7 +36,7 @@ class Generate_Plugin_List
|
||||
# Send a HTTP request to the WordPress most popular plugins webpage
|
||||
# parse the response for the plugin names.
|
||||
|
||||
def parse_plugins
|
||||
def parse_popular_plugins
|
||||
|
||||
found_plugins = []
|
||||
page_count = 1
|
||||
@@ -69,6 +69,15 @@ class Generate_Plugin_List
|
||||
|
||||
found_plugins.uniq
|
||||
end
|
||||
|
||||
def parse_full_plugins
|
||||
found_plugins = []
|
||||
index = @browser.get('http://plugins.svn.wordpress.org/').body
|
||||
index.scan(%r{<li><a href=".*">(.*)/</a></li>}i).each do |plugin|
|
||||
found_plugins << plugin[0]
|
||||
end
|
||||
found_plugins.uniq
|
||||
end
|
||||
|
||||
# Use the WordPress plugin SVN repo to find a
|
||||
# valid plugin file. This will cut down on
|
||||
@@ -88,10 +97,10 @@ class Generate_Plugin_List
|
||||
puts "[+] Parsing plugin " + plugin + " [" + response.code.to_s + "]" if @verbose
|
||||
file = response.body[%r{<li><a href="(\d*?[a-zA-Z].*\..*)">.+</a></li>}i, 1]
|
||||
if file
|
||||
# Only count Plugins with contents
|
||||
plugin += "/" + file
|
||||
plugins_with_paths << plugin + "\n"
|
||||
end
|
||||
|
||||
plugins_with_paths << plugin + "\n"
|
||||
end
|
||||
|
||||
queue_count += 1
|
||||
@@ -113,9 +122,13 @@ class Generate_Plugin_List
|
||||
|
||||
# Save the file
|
||||
|
||||
def save_file
|
||||
def save_file(full=false)
|
||||
begin
|
||||
plugins = parse_plugins
|
||||
if (full)
|
||||
plugins = parse_full_plugins
|
||||
else
|
||||
plugins = parse_popular_plugins
|
||||
end
|
||||
puts "[*] We have parsed " + plugins.size.to_s
|
||||
plugins_with_paths = parse_plugin_files(plugins)
|
||||
File.open(DATA_DIR + '/plugins.txt', 'w') { |f| f.write(plugins_with_paths) }
|
||||
|
||||
@@ -12,6 +12,9 @@ def usage()
|
||||
puts "- Generate a new 'most popular' plugin list, up to 150 pages ..."
|
||||
puts "ruby " + script_name + " --generate_plugin_list 150"
|
||||
puts
|
||||
puts "- Generate a new full plugin list"
|
||||
puts "ruby " + script_name + " --generate_full_plugin_list"
|
||||
puts
|
||||
puts "See README for further information."
|
||||
puts
|
||||
end
|
||||
@@ -24,5 +27,7 @@ def help()
|
||||
puts "--update | -u Update to the latest revision."
|
||||
puts "--generate_plugin_list [number of pages] Generate a new data/plugins.txt file. (supply number of *pages* to parse, default : 150)"
|
||||
puts "--gpl Alias for --generate_plugin_list"
|
||||
puts "--generate_full_plugin_list Generate a new full data/plugins.txt file"
|
||||
puts "--gfpl Alias for --generate_full_plugin_list"
|
||||
puts
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user