def get(self): """Interact with `get` request from front-end Currently only does Indeed, other APIs to take into consideration: USAjobs.gov, key: EwesKi7XhFETegcAroJCod5jeP9wwBkzanA1qatBMRY= AuthenticJobs.com, key: de1d14f970eaf280a271b1d5beffafe9 """ indeed_key = '4970113146490412' # not secure, coz repo, but whatevs client = IndeedClient(indeed_key) query = self.request.get_all("q") location = self.request.get_all("l") jobids = self.request.get_all("jobids") all = self.request.get_all("all") output = "" if query and not jobids: output = self.jobs(client, query, location) elif jobids and not query: output = client.jobs(tuple(jobids.split(','))) elif all != '': jobs = self.jobs(client, query, location) output = client.jobs(tuple([job.jobkey for job in jobs.results])) # for job in jobs get jobkey & use that to get all data then # colloide data on job key self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps(output))
class TestJobs(): def setup(self): self.utils = Utils() self.client = IndeedClient('8251007850639120') self.params = { 'jobkeys' : ("7c398c74a8f22c72", "d7802e9ce3b4af7d"), } def teardown(self): self.client = None self.params = None @with_setup(setup, teardown) def test_jobs(self): jobs_response = self.client.jobs(**self.params) assert type(jobs_response) is dict print jobs_response self.utils.output_to_file('output2', jobs_response) self.utils.open_with_subl('output2') self.utils.find_all_jobs_that_contains_job_parameter() # self.utils.output_to_file('sample.json', str(j)) # self.utils.open_with_subl('sample.json') @with_setup(setup, teardown) @raises(IndeedClientException) def test_missing_jobkeys(self): del self.params['jobkeys'] jobs_response = self.client.jobs(**self.params) @with_setup(setup, teardown) def test_raw_json(self): self.params['raw'] = True jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert type(json.loads(jobs_response)) is dict @with_setup(setup, teardown) def test_raw_xml_with_paramter(self): self.params['format'] = "xml" self.params['raw'] = True jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert parseString(jobs_response) @with_setup(setup, teardown) def test_raw_xml_without_paramter(self): self.params['format'] = "xml" jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert parseString(jobs_response) '''New test cases not included in GIT''' # @with_setup(setup, teardown) # def test_invalid_jobkey
class TestJobs: def setup(self): self.client = IndeedClient("YOUR_PUBLISHER_NUMBER") self.params = { 'jobkeys' : ("5898e9d8f5c0593f", "c2c41f024581eae5"), } def teardown(self): self.client = None self.params = None @with_setup(setup, teardown) def test_jobs(self): jobs_response = self.client.jobs(**self.params) assert type(jobs_response) is dict @with_setup(setup, teardown) @raises(IndeedClientException) def test_missing_jobkeys(self): del self.params['jobkeys'] jobs_response = self.client.jobs(**self.params) @with_setup(setup, teardown) def test_raw_json(self): self.params['raw'] = True jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert type(json.loads(jobs_response)) is dict @with_setup(setup, teardown) def test_raw_xml_with_paramter(self): self.params['format'] = "xml" self.params['raw'] = True jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert parseString(jobs_response) @with_setup(setup, teardown) def test_raw_xml_without_paramter(self): self.params['format'] = "xml" jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert parseString(jobs_response)
class TestJobs: def setup(self): self.client = IndeedClient("YOUR_PUBLISHER_NUMBER") self.params = { 'jobkeys': ("5898e9d8f5c0593f", "c2c41f024581eae5"), } def teardown(self): self.client = None self.params = None @with_setup(setup, teardown) def test_jobs(self): jobs_response = self.client.jobs(**self.params) assert type(jobs_response) is dict @with_setup(setup, teardown) @raises(IndeedClientException) def test_missing_jobkeys(self): del self.params['jobkeys'] jobs_response = self.client.jobs(**self.params) @with_setup(setup, teardown) def test_raw_json(self): self.params['raw'] = True jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert type(json.loads(jobs_response)) is dict @with_setup(setup, teardown) def test_raw_xml_with_paramter(self): self.params['format'] = "xml" self.params['raw'] = True jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert parseString(jobs_response) @with_setup(setup, teardown) def test_raw_xml_without_paramter(self): self.params['format'] = "xml" jobs_response = self.client.jobs(**self.params) assert isinstance(jobs_response, basestring) assert parseString(jobs_response)
Get each job key by running the search_indeed_api.py program. ''' from indeed import IndeedClient import time site = 'indeed.com' client = IndeedClient('PUBLISHER_NUMBER') # Job keys copied from the response to the search program: jk_l = ["e8930d8d162c4b70", "6bb8f41ea97bd6f8"] job_response = client.jobs(jobkeys = (jk_l )) # Example job response, Mon2016_0418. # Entire response is a dictionary. # The key 'results' has value of a list of dicts, eg: # {u'version': 2, u'results': [{u'formattedRelativeTime': u'30+ days ago', ... # ''' Each dict in the list is one job record, as shown here: {u'formattedRelativeTime': u'30+ days ago', u'city': u'San Francisco', u'date': u'Tue, 01 Mar 2016 02:31:38 GMT', u'latitude': 37.774727, u'url': u'http://www.indeed.com/rc/clk?jk=e8930d8d162c4b70&atk=', u'jobtitle': u'Jr Data Engineer', u'company': u'Komodo Health', u'formattedLocationFull': u'San Francisco, CA', u'longitude': -122.41758, u'onmousedown': u"indeed_clk(this, '');",