Sha256: c7d0923c02fcefb4dd07ccefbba9e0c49e262a5dc5dbc28b7f926a70f9079d37

Contents?: true

Size: 543 Bytes

Versions: 2

Compression:

Stored size: 543 Bytes

Contents

module IndeedJobsearch
  class SearchPage
    attr_reader :nodes
    def initialize(query, location, page_number)
      agent = Mechanize.new
      @page = agent.get(query_url(query, location, page_number))
      @nodes = @page.search('.result').map do |node|
        SearchResultNode.new(node)
      end
    end

    private

    def query_url(query, location, page_number)
      query, location = CGI.escape(query), CGI.escape(location)
      "http://www.indeed.com/jobs?q=#{query}&l=#{location}&start=#{page_number * 10}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
indeed_jobsearch-0.1.1 lib/indeed_jobsearch/search_page.rb
indeed_jobsearch-0.1.0 lib/indeed_jobsearch/search_page.rb