-
-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added an Indeed Scrapper #970
Closed
+107
−0
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1c1b5fd
Create indeed.py
Subhoshri 3c6335f
Create __init__.py
Subhoshri 9541526
Update indeed.py
Subhoshri 34ca508
Update __init__.py
Subhoshri e844152
Update dev-documentation.md
Subhoshri 57ed86b
Update dev-documentation.md
Subhoshri a57dcea
Update documentation.md
Subhoshri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .indeed import Indeed | ||
__all__= ["Indeed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
import csv | ||
from datetime import datetime | ||
|
||
class Indeed: | ||
""" | ||
Create an instance of `Indeed` class. | ||
```python | ||
indeed = Indeed() | ||
``` | ||
| Methods | Details | | ||
| ---------------------- | ------------------------------------------------------------------------------------------------ | | ||
| `.get_url()` | Returns the URL of the job having a specific position and location. | | ||
| `.get_record()` | Returns the company details like job title, company name, location, job post date, and salary. | | ||
""" | ||
|
||
def __init__(self): | ||
self.position=position | ||
self.location=location | ||
|
||
def get_url (self, position,location): | ||
template = 'https://www.indeed.com/jobs?q={}&l={}' | ||
url = template.format(position,location) | ||
return url | ||
|
||
#getting the record | ||
def get_record(self, card): | ||
atag1= card.h2.a.span | ||
job_title= atag1.get('title') | ||
atag2= card.h2.a | ||
job_url= 'https://indeed.com'+atag2.get('href') | ||
|
||
company= card.find('span','companyName').text.strip() | ||
location= card.find('div','companyLocation').text.strip() | ||
summary= card.find('div','job-snippet').text.strip() | ||
posted_date= card.find('span','date').text.strip() | ||
today= datetime.today().strftime('%Y-%m-%d') | ||
|
||
try: | ||
salary = card.find('div','metadata estimated-salary-container').text.strip() | ||
except AttributeError: | ||
salary = '' | ||
|
||
record = (job_title, job_url, location, company, posted_date, today, summary, salary) | ||
return record | ||
|
||
#writing the main function | ||
def main(self, position, location): | ||
records = [] | ||
url = get_url(position, location) | ||
|
||
while True: | ||
response=requests.get(url) | ||
soup = BeautifulSoup(response.text,'html.parser') | ||
cards=soup.find_all('div','job_seen_beacon') | ||
for card in cards: | ||
record=get_record(card) | ||
records.append(record) | ||
try: | ||
url='https://indeed.com'+soup.find('a',{'aria-label':'Next'}).get('href') | ||
except AttributeError: | ||
break | ||
|
||
with open(f'{position}-{location}.csv','w',newline='',encoding= 'utf-8') as f: | ||
writer= csv.writer(f) | ||
writer.writerow(['Job_Title', 'Job_Url', 'Location', 'Company', 'Post_Date', 'Extraction_Date', 'Summary', 'Salary']) | ||
writer.writerows(records) | ||
|
||
main('business manager', 'Geneva') #creating a demo csv file to access the records | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO not write any function to return or process the data. Just scrape the data from the platform and server it as a JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also resolve the merge conflicts @Subhoshri