indeed_scraper 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/README.md +1 -1
- data/lib/.DS_Store +0 -0
- data/lib/indeed_scraper/command_line_interface.rb +66 -92
- data/lib/indeed_scraper/job.rb +5 -11
- data/lib/indeed_scraper/scraper.rb +3 -14
- data/lib/indeed_scraper/version.rb +1 -1
- metadata +4 -17
- data/indeed_scraper-0.1.0/.gitignore +0 -9
- data/indeed_scraper-0.1.0/CODE_OF_CONDUCT.md +0 -74
- data/indeed_scraper-0.1.0/Gemfile +0 -9
- data/indeed_scraper-0.1.0/LICENSE.txt +0 -21
- data/indeed_scraper-0.1.0/README.md +0 -41
- data/indeed_scraper-0.1.0/Rakefile +0 -2
- data/indeed_scraper-0.1.0/bin/console +0 -15
- data/indeed_scraper-0.1.0/bin/run +0 -7
- data/indeed_scraper-0.1.0/bin/setup +0 -8
- data/indeed_scraper-0.1.0/indeed_scraper.gemspec +0 -42
- data/indeed_scraper-0.1.0/lib/indeed_scraper.rb +0 -13
- data/indeed_scraper-0.1.0/lib/indeed_scraper/command_line_interface.rb +0 -153
- data/indeed_scraper-0.1.0/lib/indeed_scraper/job.rb +0 -33
- data/indeed_scraper-0.1.0/lib/indeed_scraper/scraper.rb +0 -34
- data/indeed_scraper-0.1.0/lib/indeed_scraper/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6035123a97984820e9c0c374442afdea495468918f43fb6350fcd87b741d7e8e
|
4
|
+
data.tar.gz: e7bd7cb1185826b2858a3e58dee785c51bc76249a11ad47843ee7278c8c9d5b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c5837e195229672429bae7647024ac164a9093c4ae9d563e4a2fdb4b14fee260cea744c2ab50a52cdf8d26c0a2b706f4b018d6e7d41a957ce1136b3ae55af9a
|
7
|
+
data.tar.gz: c8d6c59605ca177000228cb5c96f09d3fddb9506246f68e09924ab24c8d2c6037f0c6dccb2f5febe35645a10b58e0e19c32f23fcffe7dbb482e5bdcf77a289e3
|
data/.DS_Store
ADDED
Binary file
|
data/README.md
CHANGED
data/lib/.DS_Store
ADDED
Binary file
|
@@ -2,75 +2,88 @@ class CommandLineInterface
|
|
2
2
|
|
3
3
|
BASE_PATH = "https://www.indeed.com"
|
4
4
|
|
5
|
-
def run_program
|
6
|
-
make_jobs
|
7
|
-
add_other_attributes_to_job
|
8
|
-
display_job
|
9
|
-
end
|
10
|
-
|
11
5
|
def greeting
|
12
6
|
puts "Hello there! Welcome to Indeed Scraper Command Line Interface.".green
|
13
7
|
puts "What is your name?".green
|
14
|
-
@user_name = user_input
|
15
|
-
|
16
|
-
|
8
|
+
@user_name = user_input.upcase
|
9
|
+
if !@user_name.empty?
|
10
|
+
puts " "
|
11
|
+
puts "Hello, #{@user_name}!".green
|
12
|
+
else
|
13
|
+
greeting
|
14
|
+
end
|
17
15
|
@user_name
|
18
16
|
end
|
19
17
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
18
|
+
def run_program
|
19
|
+
make_jobs
|
20
|
+
display_all_jobs
|
21
|
+
make_selection(@input)
|
23
22
|
end
|
24
23
|
|
25
24
|
def zipcode
|
26
25
|
puts "Enter your 5 digit zipcode:".green
|
27
26
|
end
|
28
|
-
|
29
|
-
def
|
30
|
-
|
27
|
+
|
28
|
+
def user_input
|
29
|
+
input = gets.strip #remove white space
|
30
|
+
@input = input
|
31
|
+
end
|
32
|
+
|
33
|
+
def select_number
|
34
|
+
puts "Enter a number from the list for more info or type 'exit' to exit program:".green
|
31
35
|
user_input
|
36
|
+
end
|
32
37
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@
|
49
|
-
|
50
|
-
|
51
|
-
|
38
|
+
def make_jobs
|
39
|
+
zipcode
|
40
|
+
user_input
|
41
|
+
puts " "
|
42
|
+
verify_zipcode
|
43
|
+
jobs_array = Scraper.scrape_index_page(@input)
|
44
|
+
Job.create_from_collection(jobs_array) # creates an array of job objects with 5 attributes
|
45
|
+
end
|
46
|
+
|
47
|
+
def make_selection(input = nil)
|
48
|
+
if @input.to_i <= Job.all.size #&& @input.to_i != 0
|
49
|
+
#retrieve job object by index number
|
50
|
+
@job = Job.all[(@input.to_i)-1]
|
51
|
+
puts "TITLE: ".blue + "#{@job.title}\n" if !@job.title.empty?
|
52
|
+
puts "COMPANY: ".blue + "#{@job.company}\n" if !@job.company.empty?
|
53
|
+
puts "LOCATION: ".blue + "#{@job.location}\n" if !@job.location.empty?
|
54
|
+
puts "SALARY: ".blue + "#{@job.salary}\n" if !@job.salary.empty?
|
55
|
+
puts "DESCRIPTION: ".blue + "#{@job.description}\n" if !@job.description.empty?
|
56
|
+
menu_list(@job.job_url)
|
57
|
+
elsif @input.upcase == "EXIT"
|
58
|
+
exit_program
|
52
59
|
else
|
60
|
+
select_number
|
53
61
|
make_selection
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
57
|
-
def menu_list
|
65
|
+
def menu_list(job_url = nil)
|
58
66
|
puts " "
|
59
67
|
puts "What do you want to do, #{@user_name}?".green
|
60
|
-
puts "
|
61
|
-
puts "1.
|
62
|
-
puts "2. Go back"
|
63
|
-
puts "3.
|
68
|
+
puts "Select a number below:\n".green
|
69
|
+
puts "1. Learn more"
|
70
|
+
puts "2. Go back to list"
|
71
|
+
puts "3. Enter new zipcode"
|
72
|
+
puts "4. Exit\n\n"
|
64
73
|
|
65
74
|
user_input
|
75
|
+
|
66
76
|
if @input.to_i == 1 #=> utilize #to_i to convert input to integer
|
67
|
-
|
68
|
-
|
69
|
-
menu_list
|
77
|
+
system("open", "#{BASE_PATH + @job.job_url}") #=> automatically open job posting via terminal
|
78
|
+
menu_list(job_url)
|
70
79
|
elsif @input.to_i == 2
|
71
|
-
|
80
|
+
display_all_jobs
|
81
|
+
make_selection(@input)
|
72
82
|
elsif @input.to_i == 3
|
73
|
-
|
83
|
+
Job.clear_all
|
84
|
+
run_program
|
85
|
+
elsif @input.to_i == 4
|
86
|
+
exit_program
|
74
87
|
else
|
75
88
|
menu_list
|
76
89
|
end
|
@@ -79,10 +92,6 @@ class CommandLineInterface
|
|
79
92
|
def verify_zipcode
|
80
93
|
if /^[0-9]{5}$/.match(@input) #=> check to see that zipcode has 5 digits
|
81
94
|
puts "Great! Here's what we found for #{@input}.".green
|
82
|
-
puts "Loading may take a few moments, so in the meantime, please enjoy this cute cat: \n\n\n".green
|
83
|
-
puts " /\\_/\\ ".magenta.blink
|
84
|
-
puts " ( o.o ) ".magenta.blink
|
85
|
-
puts " > ^ < \n\n\n\n".magenta.blink
|
86
95
|
else
|
87
96
|
puts "Hmm...that doesn't look right. Enter your 5 digit zipcode:".green
|
88
97
|
user_input
|
@@ -91,52 +100,17 @@ class CommandLineInterface
|
|
91
100
|
@input
|
92
101
|
end
|
93
102
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
puts " "
|
98
|
-
verify_zipcode
|
99
|
-
jobs_array = Scraper.scrape_index_page(@input)
|
100
|
-
Job.create_from_collection(jobs_array) # creates an array of job objects with 4 attributes
|
101
|
-
end
|
102
|
-
|
103
|
-
def add_other_attributes_to_job
|
104
|
-
Job.all.each do |job|
|
105
|
-
other_details = Scraper.scrape_job_post(BASE_PATH + job.job_url)
|
106
|
-
job.add_job_attributes(other_details)
|
103
|
+
def display_all_jobs
|
104
|
+
Job.all.each.with_index(1) do |el, index|
|
105
|
+
puts "#{index}" + ". " + "#{el.title}\n\n"
|
107
106
|
end
|
108
|
-
|
109
|
-
|
110
|
-
def display_job
|
111
|
-
Job.all.each.with_index(1) do |el, index|
|
112
|
-
#if index <= 4 #=> displays first 5 jobs in @@all array
|
113
|
-
puts "#{index}" + ". " + "#{el.title}\n\n"
|
114
|
-
end
|
115
|
-
make_selection
|
107
|
+
select_number
|
116
108
|
end
|
117
109
|
|
118
|
-
def
|
119
|
-
|
110
|
+
def exit_program
|
111
|
+
puts "See you later, #{@user_name}! Good luck on your job search!".green
|
112
|
+
puts " /\\_/\\ ".magenta.blink
|
113
|
+
puts " ( o.o ) ".magenta.blink
|
114
|
+
puts " > ^ < \n\n".magenta.blink
|
120
115
|
end
|
121
|
-
|
122
116
|
end
|
123
|
-
|
124
|
-
|
125
|
-
# prompt user for zipcode
|
126
|
-
#Great! Please enter your 5 digit zipcode:
|
127
|
-
|
128
|
-
# user types zipcode
|
129
|
-
|
130
|
-
# first scrape => grabs first 15 and create job objects
|
131
|
-
#Scraper.scrape_index_page(index)
|
132
|
-
|
133
|
-
# user selects job from list to get more info
|
134
|
-
|
135
|
-
# second scrape => display everything nicely
|
136
|
-
# attributes: type (part/full), description, wage...
|
137
|
-
|
138
|
-
# conditional => Still interested? Type yes or no
|
139
|
-
|
140
|
-
# give options to see next 5 jobs
|
141
|
-
|
142
|
-
# set variable equal to last index number?
|
data/lib/indeed_scraper/job.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Job
|
2
|
-
attr_accessor :title, :company, :description, :location, :job_url, :
|
2
|
+
attr_accessor :title, :company, :description, :location, :job_url, :salary
|
3
3
|
|
4
4
|
@@all = []
|
5
5
|
|
@@ -15,17 +15,11 @@ class Job
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def add_job_attributes(other_details)
|
19
|
-
other_details.each do |key, value|
|
20
|
-
@description = other_details[:description]
|
21
|
-
@type = other_details[:type]
|
22
|
-
end
|
23
|
-
@description = self.description
|
24
|
-
@type = self.type
|
25
|
-
end
|
26
|
-
|
27
18
|
def self.all
|
28
19
|
@@all
|
29
20
|
end
|
30
|
-
|
21
|
+
|
22
|
+
def self.clear_all
|
23
|
+
@@all.clear
|
24
|
+
end
|
31
25
|
end
|
@@ -12,23 +12,12 @@ class Scraper
|
|
12
12
|
:title => job_card.css('a').attr('title').value,
|
13
13
|
:company => job_card.css('span.company').text.strip, #remove white space
|
14
14
|
:location => job_card.css('div.location').text,
|
15
|
-
:job_url => job_card.css('a').attr('href').value
|
15
|
+
:job_url => job_card.css('a').attr('href').value,
|
16
|
+
:salary => job_card.css('span.salary').text.strip,
|
17
|
+
:description => job_card.css('span.summary').text.strip
|
16
18
|
}
|
17
19
|
job
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
def self.scrape_job_post(job_url)
|
22
|
-
html = open(job_url)
|
23
|
-
parsed_job_post = Nokogiri::HTML(html) #parse html
|
24
|
-
other_details = parsed_job_post.css('div.jobsearch-ViewJobLayout-jobDisplay')
|
25
|
-
|
26
|
-
details_hash = {}
|
27
|
-
|
28
|
-
other_details.each do |info|
|
29
|
-
details_hash[:description] = info.css('div.jobsearch-JobComponent-description p').text
|
30
|
-
details_hash[:type] = info.css('div.jobsearch-JobMetadataHeader-item').text
|
31
|
-
end
|
32
|
-
details_hash
|
33
|
-
end
|
34
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indeed_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Sheena Bonilla'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,6 +76,7 @@ executables:
|
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
|
+
- ".DS_Store"
|
79
80
|
- ".gitignore"
|
80
81
|
- CODE_OF_CONDUCT.md
|
81
82
|
- Gemfile
|
@@ -86,22 +87,8 @@ files:
|
|
86
87
|
- bin/notes
|
87
88
|
- bin/run
|
88
89
|
- bin/setup
|
89
|
-
- indeed_scraper-0.1.0/.gitignore
|
90
|
-
- indeed_scraper-0.1.0/CODE_OF_CONDUCT.md
|
91
|
-
- indeed_scraper-0.1.0/Gemfile
|
92
|
-
- indeed_scraper-0.1.0/LICENSE.txt
|
93
|
-
- indeed_scraper-0.1.0/README.md
|
94
|
-
- indeed_scraper-0.1.0/Rakefile
|
95
|
-
- indeed_scraper-0.1.0/bin/console
|
96
|
-
- indeed_scraper-0.1.0/bin/run
|
97
|
-
- indeed_scraper-0.1.0/bin/setup
|
98
|
-
- indeed_scraper-0.1.0/indeed_scraper.gemspec
|
99
|
-
- indeed_scraper-0.1.0/lib/indeed_scraper.rb
|
100
|
-
- indeed_scraper-0.1.0/lib/indeed_scraper/command_line_interface.rb
|
101
|
-
- indeed_scraper-0.1.0/lib/indeed_scraper/job.rb
|
102
|
-
- indeed_scraper-0.1.0/lib/indeed_scraper/scraper.rb
|
103
|
-
- indeed_scraper-0.1.0/lib/indeed_scraper/version.rb
|
104
90
|
- indeed_scraper.gemspec
|
91
|
+
- lib/.DS_Store
|
105
92
|
- lib/indeed_scraper.rb
|
106
93
|
- lib/indeed_scraper/command_line_interface.rb
|
107
94
|
- lib/indeed_scraper/job.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at 'sheena.myb@gmail.com'. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2018 'Sheena Bonilla'
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# IndeedScraper
|
2
|
-
|
3
|
-
Welcome to Indeed Scraper! This CLI (Command Line Interface) Gem was created to provide assistance in finding employment. Data is extracted from an external source (i.e. www.indeed.com) and displayed as the following attributes: title, company, location, hours/salary, job url, and a short description.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'indeed_scraper'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install indeed_scraper
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
jobs = IndeedScraper::Job.
|
24
|
-
|
25
|
-
## Development
|
26
|
-
|
27
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/run` for an interactive prompt that will allow you to experiment.
|
28
|
-
|
29
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
-
|
31
|
-
## Contributing
|
32
|
-
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/'essbee808'/indeed_scraper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
34
|
-
|
35
|
-
## License
|
36
|
-
|
37
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
38
|
-
|
39
|
-
## Code of Conduct
|
40
|
-
|
41
|
-
Everyone interacting in the IndeedScraper project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'essbee808'/indeed_scraper/blob/master/CODE_OF_CONDUCT.md).
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#=> tells the shell which interpreter to use to execute the remainder of the file.
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "indeed/scraper"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|
@@ -1,42 +0,0 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "indeed_scraper/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "indeed_scraper"
|
8
|
-
spec.version = IndeedScraper::VERSION
|
9
|
-
spec.authors = ["'Sheena Bonilla'"]
|
10
|
-
spec.email = ["'sheena.myb@gmail.com'"]
|
11
|
-
spec.files = ["lib/indeed_scraper.rb"]
|
12
|
-
spec.summary = %q{Indeed Scraper was created to provide assistance in finding employment.}
|
13
|
-
spec.description = %q{Data is extracted from an external source (i.e. www.indeed.com) and displayed as the following attributes: title, location, hours/salary, job url, and a short description.}
|
14
|
-
spec.homepage = "https://github.com/essbee808/indeed_scraper"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
# if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata["allowed_push_host"] = "https://rubygems.org/profiles/essbee808"
|
21
|
-
|
22
|
-
# spec.metadata["homepage_uri"] = spec.homepage
|
23
|
-
# spec.metadata["source_code_uri"] = "https://github.com/essbee808/indeed_scraper.git"
|
24
|
-
# else
|
25
|
-
# raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
-
# "public gem pushes."
|
27
|
-
# end
|
28
|
-
|
29
|
-
# Specify which files should be added to the gem when it is released.
|
30
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
-
end
|
34
|
-
spec.bindir = "exe"
|
35
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
-
spec.require_paths = ["lib"]
|
37
|
-
|
38
|
-
spec.add_development_dependency "bundler", "~> 1.17"
|
39
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
-
spec.add_dependency "colorize", "0.8"
|
41
|
-
spec.add_dependency "nokogiri", "1.8.5"
|
42
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
#environment file
|
2
|
-
#require Gems
|
3
|
-
require 'pry'
|
4
|
-
require 'nokogiri'
|
5
|
-
require 'open-uri'
|
6
|
-
require 'colorize'
|
7
|
-
|
8
|
-
require_relative "indeed_scraper/version"
|
9
|
-
require_relative "indeed_scraper/command_line_interface"
|
10
|
-
require_relative "indeed_scraper/job"
|
11
|
-
require_relative "indeed_scraper/scraper"
|
12
|
-
|
13
|
-
#when referencing, don't need .rb
|
@@ -1,153 +0,0 @@
|
|
1
|
-
class CommandLineInterface
|
2
|
-
|
3
|
-
BASE_PATH = "https://www.indeed.com"
|
4
|
-
|
5
|
-
def run_program
|
6
|
-
greeting
|
7
|
-
make_jobs
|
8
|
-
add_other_attributes_to_job
|
9
|
-
display_job
|
10
|
-
end
|
11
|
-
|
12
|
-
def greeting
|
13
|
-
puts "Hello there! Welcome to Indeed Scraper Command Line Interface.".green
|
14
|
-
puts "What is your name?".green
|
15
|
-
@user_name = user_input
|
16
|
-
puts " "
|
17
|
-
puts "Aloha, #{@input}!".green
|
18
|
-
puts "Enter your 5 digit zipcode:".green
|
19
|
-
end
|
20
|
-
|
21
|
-
#User's input
|
22
|
-
def user_input
|
23
|
-
input = gets.strip #remove white space
|
24
|
-
@input = input
|
25
|
-
end
|
26
|
-
|
27
|
-
def make_selection
|
28
|
-
puts " "
|
29
|
-
puts "Select a number from the list above for more info.".green
|
30
|
-
puts "Enter a number:".green
|
31
|
-
user_input
|
32
|
-
|
33
|
-
if @input.to_i.between?(1, 15)
|
34
|
-
puts " "
|
35
|
-
job = Job.all[@input.to_i-1]
|
36
|
-
|
37
|
-
puts " "
|
38
|
-
puts "TITLE: ".blue + "#{job.title}\n" if !job.title.empty?
|
39
|
-
puts "COMPANY: ".blue + "#{job.company}\n" if !job.company.empty?
|
40
|
-
puts "HOURS/SALARY: ".blue + "#{job.type}\n" if !job.type.empty?
|
41
|
-
puts "LOCATION: ".blue + "#{job.location}\n\n" if !job.location.empty?
|
42
|
-
if !job.description.empty?
|
43
|
-
puts "DESCRIPTION: \n".blue
|
44
|
-
puts "#{job.description}\n"
|
45
|
-
end
|
46
|
-
menu_list
|
47
|
-
else
|
48
|
-
make_selection
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def menu_list
|
53
|
-
puts " "
|
54
|
-
puts "What do you want to do, #{@user_name}?".green
|
55
|
-
puts "Enter a number:\n".green
|
56
|
-
puts "1. Apply"
|
57
|
-
puts "2. Go back"
|
58
|
-
puts "3. Exit\n"
|
59
|
-
|
60
|
-
user_input
|
61
|
-
# binding.pry
|
62
|
-
if @input.to_i == 1
|
63
|
-
job = Job.all[@input.to_i-1]
|
64
|
-
puts "To apply, right click on the link below then select 'Open URL'.".green
|
65
|
-
puts " "
|
66
|
-
puts BASE_PATH + job.job_url
|
67
|
-
menu_list
|
68
|
-
elsif @input.to_i == 2
|
69
|
-
display_job
|
70
|
-
elsif @input.to_i == 3
|
71
|
-
puts " "
|
72
|
-
puts "See you later, #{@user_name}! Good luck on your job search!".green
|
73
|
-
else
|
74
|
-
menu_list
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def verify_zipcode
|
79
|
-
if /^[0-9]{5}$/.match(@input)
|
80
|
-
puts "Great! We found some cool jobs for #{@input}.".green
|
81
|
-
puts "Loading may take a few moments, so in the meantime, please enjoy this cute cat: \n\n\n".green
|
82
|
-
puts " /\\_/\\ ".magenta.blink
|
83
|
-
puts " ( o.o ) ".magenta.blink
|
84
|
-
puts " > ^ < \n\n\n\n".magenta.blink
|
85
|
-
else
|
86
|
-
puts "Hmm...that doesn't look right. Enter your 5 digit zipcode:".green
|
87
|
-
user_input
|
88
|
-
verify_zipcode
|
89
|
-
end
|
90
|
-
@input
|
91
|
-
end
|
92
|
-
|
93
|
-
def make_jobs
|
94
|
-
user_input
|
95
|
-
puts " "
|
96
|
-
verify_zipcode
|
97
|
-
jobs_array = Scraper.scrape_index_page(@input)
|
98
|
-
Job.create_from_collection(jobs_array) # creates an array of job objects with 4 attributes
|
99
|
-
end
|
100
|
-
|
101
|
-
def add_other_attributes_to_job
|
102
|
-
Job.all.each do |job|
|
103
|
-
other_details = Scraper.scrape_job_post(BASE_PATH + job.job_url)
|
104
|
-
job.add_job_attributes(other_details)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def display_job
|
109
|
-
Job.all.each.with_index(1) do |el, index|
|
110
|
-
#if index <= 4 #=> displays first 5 jobs in @@all array
|
111
|
-
puts "#{index}" + ". " + "#{el.title}\n\n"
|
112
|
-
end
|
113
|
-
make_selection
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
#display first 5 jobs
|
119
|
-
#prompt user to make a selection or type 'more' for more choices
|
120
|
-
#if user selects index 0-4
|
121
|
-
# display details for job object
|
122
|
-
# ask for user input
|
123
|
-
# prompts: apply (display url) or go back?
|
124
|
-
#elsif user selects 'more'
|
125
|
-
# pull next 5 job objects from array
|
126
|
-
# display as 1-5?
|
127
|
-
# ask for user input
|
128
|
-
# prompt: make a selection or type 'more' for more choices
|
129
|
-
#else
|
130
|
-
# loop
|
131
|
-
#end
|
132
|
-
|
133
|
-
|
134
|
-
# prompt user for zipcode
|
135
|
-
#Great! Please enter your 5 digit zipcode:
|
136
|
-
|
137
|
-
# user types zipcode
|
138
|
-
|
139
|
-
# first scrape => grabs first 15 and create job objects
|
140
|
-
#Scraper.scrape_index_page(index)
|
141
|
-
|
142
|
-
# display 5 jobs at a time
|
143
|
-
|
144
|
-
# user selects job from list to get more info
|
145
|
-
|
146
|
-
# second scrape => display everything nicely
|
147
|
-
# attributes: type (part/full), description, wage...
|
148
|
-
|
149
|
-
# conditional => Still interested? Type yes or no
|
150
|
-
|
151
|
-
# give options to see next 5 jobs
|
152
|
-
|
153
|
-
# set variable equal to last index number?
|
@@ -1,33 +0,0 @@
|
|
1
|
-
class Job
|
2
|
-
attr_accessor :title, :company, :description, :location, :job_url, :type
|
3
|
-
|
4
|
-
@@all = []
|
5
|
-
|
6
|
-
def initialize(job_hash)
|
7
|
-
job_hash.each {|key, value| self.send(("#{key}="), value)}
|
8
|
-
@@all << self
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.create_from_collection(jobs_array)
|
12
|
-
jobs_array.each do |hash|
|
13
|
-
new_job = self.new(hash)
|
14
|
-
new_job
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_job_attributes(other_details)
|
19
|
-
#iterate over attributes_hash
|
20
|
-
#use metaprogramming; assign job attributes and values using send method
|
21
|
-
other_details.each do |key, value|
|
22
|
-
@description = other_details[:description]
|
23
|
-
@type = other_details[:type]
|
24
|
-
end
|
25
|
-
@description = self.description
|
26
|
-
@type = self.type
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.all
|
30
|
-
@@all
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
class Scraper
|
2
|
-
|
3
|
-
BASE_PATH = "https://www.indeed.com"
|
4
|
-
|
5
|
-
def self.scrape_index_page(input)
|
6
|
-
html = open(BASE_PATH + "/l-#{input}-jobs.html") # interpolate input
|
7
|
-
parsed_page = Nokogiri::HTML(html)
|
8
|
-
all_jobs = parsed_page.css('div.jobsearch-SerpJobCard')
|
9
|
-
|
10
|
-
all_jobs.collect do |job_card|
|
11
|
-
job = {
|
12
|
-
:title => job_card.css('a').attr('title').value,
|
13
|
-
:company => job_card.css('span.company').text.strip, #remove white space
|
14
|
-
:location => job_card.css('div.location').text,
|
15
|
-
:job_url => job_card.css('a').attr('href').value
|
16
|
-
}
|
17
|
-
job
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.scrape_job_post(job_url)
|
22
|
-
html = open(job_url)
|
23
|
-
parsed_job_post = Nokogiri::HTML(html) #parse html
|
24
|
-
other_details = parsed_job_post.css('div.jobsearch-ViewJobLayout-jobDisplay')
|
25
|
-
|
26
|
-
details_hash = {}
|
27
|
-
|
28
|
-
other_details.each do |info|
|
29
|
-
details_hash[:description] = info.css('div.jobsearch-JobComponent-description p').text
|
30
|
-
details_hash[:type] = info.css('div.jobsearch-JobMetadataHeader-item').text
|
31
|
-
end
|
32
|
-
details_hash
|
33
|
-
end
|
34
|
-
end
|