Create a gist now

Instantly share code, notes, and snippets.

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