Skip to content

Instantly share code, notes, and snippets.

@a-bx
Created April 23, 2015 19:30
Show Gist options
  • Save a-bx/a50beab969a1938b4764 to your computer and use it in GitHub Desktop.
Save a-bx/a50beab969a1938b4764 to your computer and use it in GitHub Desktop.
GetOnBoard Scrapp
require 'mechanize'
def parse_offer(link, goal)
agent = Mechanize.new
agent.get link
salary = agent.page.search('[itemprop="baseSalary"]')
salary_value = salary.first.attributes['content'].value
dolars = salary_value.to_i
title = agent.page.search('[itemprop="title"]').first.text
return nil unless dolars >= goal
{:dolars => dolars, :title => title, :link => link}
end
def parse_list(url, goal)
agent = Mechanize.new
home = agent.get url
offers = []
list = agent.page.search(".job-list")
list.children.each do |l|
has_money = l.search(".fa-money").count > 0
if has_money
link = l.search("a").first.attributes['href'].text
offer = parse_offer(link, goal)
p offer
offers.push offer if offer
end
end
offers
end
parse_list "https://www.getonbrd.cl/empleos/programacion", 3500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment