Bataille
Bataille is smart custom web searcher and analyzer for SEO.
Installation
Add this line to your application's Gemfile:
gem 'bataille'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bataille
Usage
Search
results = Bataille::Search.google_search("test") #=> #<Bataille::SearchResult>
site = results.first #=> #<Bataille::Site>
site.url #=> "test.jp/"
site.title #=> "test title"
site.description #=> "test description"
site.rank #=> 1 //search result page ranking
or you can specify the number of result, default length is 10
result = Bataille::Search.google_search("test", 20)
result.length # 20
you can use finder for search result
results = Bataille::Search.google_search("test")
results.where(title: "hoge")
results.where(description: "fuga")
results.where(url: /com$/)
# you can chain finders
results.where(title: "hoge").where(url: /com$/)
# or
results.where({title: "hoge", url: /com$/})
Bataille::SearchResult#where returns another Bataille::SearchResult instance.
if you want to get the only 1 result, use '#find_by'
results.find_by(:url, /com$/) #=> #<Bataille::Site>
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request