Created
April 29, 2011 07:39
-
-
Save MelanieS/947996 to your computer and use it in GitHub Desktop.
Google SERP Checker
This file contains hidden or 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
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