Skip to content
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

glassdoor crawler #12

Merged
merged 3 commits into from
Oct 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions joble/spiders/glassdoor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
import scrapy
import urllib

# scrapy crawl Glassdoor
class GlassdoorSpider(scrapy.Spider):
name = 'Glassdoor'
allowed_domains = ['glassdoor.com']
url = 'https://www.glassdoor.com'

def __init__(self, keyword=None, count=20):
self.keyword = keyword
self.count = int(count)

def start_requests(self):
url = '{}/Job/jobs.htm?sc.keyword={}'.format(self.url, self.keyword)
yield scrapy.Request(url=url, callback=self.parse)

def parse(self, response):
elements = response.css('ul.jlGrid li.react-job-listing')

for element in elements[:self.count]:
job = {
'title': element.attrib['data-normalize-job-title'],
'location': element.attrib['data-job-loc'],
'employer': self.url + element.css('div div.jobHeader a span::text').get(),
'job-link': element.css('div div.jobHeader a::attr(href)').get()
}
yield job