-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtimesjobs.py
54 lines (42 loc) · 1.51 KB
/
timesjobs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json
import requests
import time
import traceback
def addBlanks(row):
for i in row:
if row[i] is None:
row[i] = ''
def scrape():
timestamp = time.time()
headers = json.load(open('headers.json'))
json_filename = './files/timesjobs.json'
fp = open(json_filename, 'w')
url = 'https://jobbuzz.timesjobs.com/jobbuzz/loadMoreJobs.json?companyIds=&locationnames=198130$&aosValues=&sortby=Y&from=filter&faids=&txtKeywords=&pSize=50'
response = requests.get(url)
jobs = json.loads(response.text)
jobs = jobs['jobsList']
joblist = []
for job in jobs:
row = dict.fromkeys(headers)
row['title'] = job['title']
row['applylink'] = 'http://www.timesjobs.com/candidate/' + job['jdUrl']
row['jd'] = job['jobDesc']
row['companyname'] = job['companyName']
row['location'] = job['Location']
row['salary'] = job['salary']
row['skills'] = ", ".join([x.strip().strip("\"") for x in job['keySkills']])
row['enddate'] = job['expiry']
row['source'] = 'timesjobs'
row['experience'] = job['experience'] + " yrs"
row['timestamp'] = timestamp
addBlanks(row)
print(row)
joblist.append(row)
json.dump(joblist, fp)
fp.close()
try:
scrape()
except Exception as ex:
with open("error.log", 'a') as errorlog:
#print(time.asctime() + ":" + ex, file=errorlog)
traceback.print_exc(file=errorlog)