Class: JobHunterCli::Scraper
- Inherits:
-
Object
- Object
- JobHunterCli::Scraper
- Defined in:
- lib/job_hunter_cli/scraper.rb
Instance Attribute Summary collapse
-
#co ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance.
-
#l ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance.
-
#limit ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance.
-
#q ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance.
-
#radius ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance.
-
#uri ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance.
Instance Method Summary collapse
Instance Attribute Details
#co ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance
3 4 5 |
# File 'lib/job_hunter_cli/scraper.rb', line 3 def co @co end |
#l ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance
3 4 5 |
# File 'lib/job_hunter_cli/scraper.rb', line 3 def l @l end |
#limit ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance
3 4 5 |
# File 'lib/job_hunter_cli/scraper.rb', line 3 def limit @limit end |
#q ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance
3 4 5 |
# File 'lib/job_hunter_cli/scraper.rb', line 3 def q @q end |
#radius ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance
3 4 5 |
# File 'lib/job_hunter_cli/scraper.rb', line 3 def radius @radius end |
#uri ⇒ Object
save instace variables to assign in teh CLI class when creating a new Scraper instance
3 4 5 |
# File 'lib/job_hunter_cli/scraper.rb', line 3 def uri @uri end |
Instance Method Details
#scrape_jobs ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/job_hunter_cli/scraper.rb', line 5 def scrape_jobs # indeed.com api uses XML. To parse in XLM use Nokogiri uri = "http://api.indeed.com/ads/apisearch?publisher=3881286689960538&#{@q}&#{@l}&sort=date&#{@radius}&st=&jt=&start=&#{@limit}&fromage=&filter=&latlong=1&#{@co}&chnl=&userip=1.2.3.4&useragent=Mozilla/%2F4.0%28Firefox%29&v=2" jobs_array = [] jobs_hash = {} doc = Nokogiri::XML(open(uri)) doc.css("result").each do |job_result| jobs_hash = { job_role: job_result.css("jobtitle").text, company: job_result.css("company").text, city: job_result.css("city").text, state: job_result.css("state").text, country: job_result.css("country").text, url: job_result.css("url").text, description: job_result.css("snippet").text, date_posted: job_result.css("date").text, post_duration: job_result.css("formattedRelativeTime").text } jobs_array << jobs_hash end # end of each statement jobs_array end |