Skip to content

Instantly share code, notes, and snippets.

@MelanieS
Created April 29, 2011 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelanieS/947996 to your computer and use it in GitHub Desktop.
Save MelanieS/947996 to your computer and use it in GitHub Desktop.
Google SERP Checker
require 'sinatra'
get '/serp_checker' do
"<form action='/ranked' method='post'>
<label for='keyword'>Keyword</label>
<textarea name='keyword' id='keyword' type='text' /></textarea>
<label for='url'>URL</label>
<input name='url' id='url' type='text' />
<input type='submit' value='Go!' />
</form>"
end
def clean_up_keywords(str)
str.gsub("\n", ",").delete("\r").split(',')
end
def clean_up_list(arr)
arr.reject(&:empty?).each(&:lstrip!)
end
post '/ranked' do
dirty_list = clean_up_keywords(params[:keyword])
clean_list = clean_up_list(dirty_list)
return clean_list.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment